Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for resource-id #21101

Closed
wants to merge 1 commit into from
Closed

Add support for resource-id #21101

wants to merge 1 commit into from

Conversation

lightboys22
Copy link

@lightboys22 lightboys22 commented Sep 13, 2018

Track react tag using android.view.View.tag. Allow developers to set resource id by setting component.testID

Fixes #9777

Test Plan

First, you need to declare the resource id by creating /your_android_studio_folder/res/values/ids.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="my_test_id"/>
</resources>

Second, set the testID of your component to a resource name.

<Button
onPress={onButtonPress}
title="Press Me"
testID='test_id'
/>

Third, run the app and observe the resource id using UIAutomator viewer (/Android/sdk/tools/bin/uiautomatorviewer)

Changelog

[ANDROID] [Fixes] - BaseViewManager: Allow developers to set resource id by setting component.testID

Squashed commits:
[f0f046f] Fixes #9777 Add support for resource-id
Track react tag using android.view.View.tag. Allow developers to set resource id by setting component.testID

This pull request fixes the following issue.
#9777

First, you need to declare the resource id by creating /_your_android_studio_folder_/res/values/ids.xml

```
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="my_test_id"/>
</resources>
```

Second, set the testID of your component to a resource name.

```
<Button
onPress={onButtonPress}
title="Press Me"
testID='test_id'
/>
```

Third, run the app and observe the resource id using UIAutomator viewer (/Android/sdk/tools/bin/uiautomatorviewer)

This PR doesn't require a documentation change.

[ANDROID] [BUGFIX] [com/facebook/react/uimanager/BaseViewManager] - Allow developers to set resource id by setting component.testID
[1ae19f5] Fixes #9777 Add support for resource-id
Track react tag using android.view.View.tag. Allow developers to set resource id by setting component.testID

This pull request fixes the following issue.
#9777

First, you need to declare the resource id by creating /_your_android_studio_folder_/res/values/ids.xml

```
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="my_test_id"/>
</resources>
```

Second, set the testID of your component to a resource name.

```
<Button
onPress={onButtonPress}
title="Press Me"
testID='test_id'
/>
```

Third, run the app and observe the resource id using UIAutomator viewer (/Android/sdk/tools/bin/uiautomatorviewer)

This PR doesn't require a documentation change.

[ANDROID] [BUGFIX] [com/facebook/react/uimanager/BaseViewManager] - Allow developers to set resource id by setting component.testID
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 13, 2018
@craigrbruce
Copy link

@lightboys22 This is great work! I would suggest renaming testId as we have other applications for this facility beyond testing, namely gaining control of navigation (using a d-pad for example).

Perhaps a better name would be resource-id?

@hramos
Copy link
Contributor

hramos commented Feb 14, 2019

Is this a duplicate of #18527, which you also opened?

@hramos hramos changed the title Fixes facebook/react-native#9777 Add support for resource-id Add support for resource-id Feb 14, 2019
@cpojer
Copy link
Contributor

cpojer commented Apr 4, 2019

@lightboys22 could you rebase this commit on master? Let's figure out how to get this merged!

@lightboys22
Copy link
Author

@cpojer Hi Christopher,
You honored me with your presence. My team bypassed this issue by using Espresso.

Although Espresso only allows us to find UI elements by it content-description, Espresso is good enough for us.

@lightboys22 lightboys22 closed this Apr 4, 2019
@harking
Copy link

harking commented Oct 28, 2019

@cpojer We've recently run into this again for some of our projects. Are you still open to including this fix?

@lightboys22
Copy link
Author

@harking I am too lazy to continue to work on this pull request. My previous team was using Espresso, which allow you to find elements based on the “test-is” view tag.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for resource-id
7 participants