-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for resource-id #9777
Comments
@tuckerconnelly referenced @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 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> cc @jasonfma @talarari @sondremare @sijicl @JuliusMalisauskasDB @atom992 @jdeff |
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* This closes facebook#9777.
* Calling view.setId() with the matching resource-id of an id found in R.class. Added TestIdUtil to facilitate this. * Updating the android sample project to include a testID example. Updating the e2e test to use it. * Changing the signature for virtually all Event Classes to require the View instead of the viewTag. This reduces the number of locations where TestIdUtil.getOriginalReactTag is called. * Minimizing the impact in non __DEV__ environments where testID should not be set by simply returning view.getId() in TestIdUtil.getOriginalReactTag. * This closes facebook#9777.
* Calling view.setId() with the matching resource-id of an id found in R.class. Added TestIdUtil to facilitate this. * Updating the android sample project to include a testID example. Updating the e2e test to use it. * Changing the signature for virtually all Event Classes to require the View instead of the viewTag. This reduces the number of locations where TestIdUtil.getOriginalReactTag is called. * Minimizing the impact in non __DEV__ environments where testID should not be set by simply returning view.getId() in TestIdUtil.getOriginalReactTag. * This closes facebook#9777.
* Calling view.setId() with the matching resource-id of an id found in R.class. Added TestIdUtil to facilitate this. * Updating the android sample project to include a testID example. Updating the e2e test to use it. * Changing the signature for virtually all Event Classes to require the View instead of the viewTag. This reduces the number of locations where TestIdUtil.getOriginalReactTag is called. * Minimizing the impact in non __DEV__ environments where testID should not be set by simply returning view.getId() in TestIdUtil.getOriginalReactTag. * This closes facebook#9777.
* Calling view.setId() with the matching resource-id of an id found in R.class. Added TestIdUtil to facilitate this. * Updating the android sample project to include a testID example. Updating the e2e test to use it. * Changing the signature for virtually all Event Classes to require the View instead of the viewTag. This reduces the number of locations where TestIdUtil.getOriginalReactTag is called. * Minimizing the impact in non __DEV__ environments where testID should not be set by simply returning view.getId() in TestIdUtil.getOriginalReactTag. * This closes facebook#9777.
* Calling view.setId() with the matching resource-id of an id found in R.class. Added TestIdUtil to facilitate this. * Updating the android sample project to include a testID example. Updating the e2e test to use it. * Changing the signature for virtually all Event Classes to require the View instead of the viewTag. This reduces the number of locations where TestIdUtil.getOriginalReactTag is called. * Minimizing the impact in non __DEV__ environments where testID should not be set by simply returning view.getId() in TestIdUtil.getOriginalReactTag. * This closes facebook#9777.
@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. Also, if this issue is a bug, please consider sending a PR with a fix. |
@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. |
Yes we need this as well. |
Something new about this issue? |
+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? |
Issue Description
There currently isn't a way to find elements by resource-id using appium/uiautomatorviewer.
react-native
currently supportscontentDescription
viaaccessibilityLabel
. 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 howandroid:id
could be added to a view then I'd most certainly be willing to give it a shot. My understanding ofandroid: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.Steps to Reproduce / Code Snippets
testID="something"
to any component (e.g.View
)uiautomatorviewer
You'll notice that
resource-id
is emptyExpected Results
resource-id
has a value likecom.myApp:id/something
Additional Information
0.32
The text was updated successfully, but these errors were encountered: