Accessing React Elements using Appium for Automation

Based on this link : https://github.com/facebook/react-native/issues/7135

The workaround for this problem : use both accessible and accessibleLabel on your views

DOC on accessiblity label: https://facebook.github.io/react-native/docs/accessibility.html#accessibilitylabel-ios-android

On my react native component :

<TextInput accessible={true} accessibilityLabel={'Tap Me'}></TextInput>

On my script Test :

mobileElement = find_Element(accessibilty_id, "Tap Me")
mobileElement.send_keys "hello world"

The standalone inspector can be used to identify the react elements like "react-devtools".

Steps to Install the react-devtools standalone app:

  • yarn global add react-devtools
  • Once installed run the following command in terminal "react-devtools". From the in app developer menu click on "Toggle Inspector" and click on inspect to inspect element.

    It will connect automatically for RN 0.43 or higher. An element can be found easily with this. Consider reading this