Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No ID for my Android UI Testing

I would like to write some UI Test on my Android application in order to take automated screenshots.

My application is written with React-Native.

In order to write my tests in need to know the resource-id of my component but as you can see in this screenshot i can't see any resource-id with ui Automator Viewer in this React-Native example app.

Look this picture.

I would like to know if there is a way to give some IDs to my components so I can write some test or if there is another way to select my components.

Note : I'm trying to write Espresso Test.

like image 711
G.Sabathier Avatar asked May 23 '16 09:05

G.Sabathier


1 Answers

The testID only works on iOS, and is not mapped to the resource-id in Android.

You can specify an accessibilityLabel to your component. In uiautomatorviewer it shows up as content-desc

To be cross-platform, you should specify both:

<Text style={styles.welcome} accessibilityLabel="MyId" testID="MyId">
  Welcome!
</Text>

You can then search for it using something like webdriver with the tilde selector browser.waitForExist("~MyId")

like image 187
eleventy Avatar answered Oct 22 '22 02:10

eleventy