There currently isn't a way to find elements by resource-id using appium/uiautomatorviewer.
react-native currently supports contentDescription via accessibilityLabel. This is great for clickable elements, but not so great for testing other things like splash screen visibility.
I'd be more than willing to add support for this, but am currently not aware of how react-native builds the android views. If someone could give me some guidance on how android:id could be added to a view then I'd most certainly be willing to give it a shot. My understanding of android:id (per the View docs on IDs), is that it must be set in the XML prior to view creation.
I don't believe this is a duplicate of #7135, because I'm not proposing that we break the way testID currently works, more that I feel it would be nice if testID could add it's value to the corresponding view component in the XML.
testID="something" to any component (e.g. View)uiautomatorviewerYou'll notice that resource-id is empty

resource-id has a value like com.myApp:id/something
0.32@tuckerconnelly referenced BaseViewManager here. I'm thinking it could be modified to do something like this:
@ReactProp(name = PROP_TEST_ID)
public void setTestId(T view, String testId) {
try {
view.setId(R.id.class.getField(testId).getInt(null));
} catch (Exception e) {
// swallow
}
view.setTag(testId);
}
The trick is gaining access to R which resides in the application's package.
If that were in place, the only thing you'd need to do is create a resource file for the ids you'll be referencing:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="something" type="id"/>
</resources>
Thoughts @ide @mkonicek?
cc @jasonfma @talarari @sondremare @sijicl @JuliusMalisauskasDB @atom992 @jdeff
@facebook-github-bot label Icebox
Hi there! This issue is being closed because it has been inactive for a while.
But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/add-support-for-resource-id
ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub.
Also, if this issue is a bug, please consider sending a PR with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.
@facebook-github-bot close
@charpeni tells me to close this issue. If you think it should still be opened let us know why.
I am testing a react-native application and I do feel I require the support for resource-id. Can you guys open up this ticket again?
I have the same trouble, for Robo tests needed resource-id for each page component.
Any news about this? Very need this functional. :disappointed:
Yes we need this as well.
Something new about this issue?
My testing crew is stuck without this. ;/
+1 that this will help testing
+1 need this for testing
PLZ, make us happy. Add resource-id support
+1, Please. It will make life easier.
+1
My workaround for testing right now is accessibility Label. However, this does not help with prelaunch Google Play testing :(
+1 our team finds this feature really helpful. Are there any plans on moving this forward?
Most helpful comment
I am testing a react-native application and I do feel I require the support for resource-id. Can you guys open up this ticket again?