GithubHelp home page GithubHelp logo

betonix / react-native-fastlane-screenshot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cnordbo/react-native-fastlane-screenshot

0.0 1.0 0.0 924 KB

Tutorial \ How-to: Take screenshots using react-native and fastlane snapshot

JavaScript 7.31% Java 4.99% Objective-C 14.17% Swift 42.07% Ruby 3.26% HTML 22.12% Starlark 6.08%

react-native-fastlane-screenshot's Introduction

How to take Screenshots with fastlane using React Native

Setup

Follow the setup guide on fastlanes website

Further actions

  1. Open xCode -> Product -> Scheme -> Edit Sceme
  2. (optional) In all windows, select (Release) as build configuration (not needed, but helps you avoid yellow box warnings during screenshots)
  3. Make sure Executable is set to your app
  4. Under "Build" - De-select "parallelize build"
  5. Under "Build" - Make sure "Test" and "Run" is selected for the test target.
  6. Close the Schema Window
  7. Select your root project -> Select your UI Test Target -> Build Phases -> expand "Target dependencies"
  8. Add "React" as a target dependency.

Setup your screenshot procedure (see below) - and run fastlane snapshot.

Tip

If you have not already done so, move your Fastlane files into /fastlane folder, fastlane will automatically look for supported files here, and helps you keep your project organized.

How to write screenshot procedure.

Give the elements you want to tap a testID="<yourID>"

Ex.

<TouchableOpacity testID="BTN2" onPress={() => {}}>
  <Text>Touch me</Text>
</TouchableOpacity>

(HARD) In your testfile, where you normally record - You can try the recorder, but be very carefull of the points your touching - Its very picky that way.

(EASIER) I think its easier to be explicit about it - TouchableOpacity seems to allways show up in "otherElements" no matter how deep its nested:

// Helps us not to continue before react has compiled its stuff and actually loaded the application
XCUIApplication().otherElements["BTN2"].waitForExistence(timeout: 30) 
 //Take the screenshot and give it a name of "01Launch"
snapshot("01Launch")
// Tap the element with testID="BTN2"
XCUIApplication().otherElements["BTN2"].tap()
snapshot("02BTN2State")
// Wait 1 second before continuing
sleep(1)
XCUIApplication().otherElements["BTN1"].tap()
snapshot("03BTN1State")

Testing tips:

Dynamic content? Set your testID=´MyContent_${index}´

To be figgured out

  • Fastlane complains about not installed languages and defaults to system default.
  • Simulator gets erased everytime, makes it hard to use asyncStorage and setting up testdata. (even if erase_simluator = false)

Contribute

If you find anything worthy of a mention, submit a PR or create an issue.

react-native-fastlane-screenshot's People

Contributors

cnordbo avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.