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

testID information not visible on UIAutomator in Appium. #7135

Closed
kahn004 opened this Issue Apr 22, 2016 · 24 comments

Comments

Projects
None yet
@kahn004
Copy link

kahn004 commented Apr 22, 2016

Hi there,

We are doing an automation test for Android (API version 21) on Appium.

And we are using UI Automator Viewer to see the node details information and we need resource-id information visible in order to test for unique nodes so we know which elements are being interacted.

But currently, resource-id column is empty even though we have applied testId property on each <View>.

Please close this issue if there is a duplicate, otherwise please advise on what we can do to have each nodes to have unique id's specified from testId value provided.

Thanks,

Sam

@ashleydw

This comment has been minimized.

Copy link

ashleydw commented Apr 25, 2016

I too struggled with this and actually gave up on android testing with appium.

Appium is in the process of upgrading to uiautomator v2 which can find by tags because we have the full instrumentation API available. It'll probably take a very long time to be ready though. In uiautomator v1 (what appium currently uses), this isn't possible.

The only work around I know of is exactly what you mentioned, strip the automaton only content descriptions out of production builds.

See https://discuss.appium.io/t/react-native-ui-element-access-via-testid

@atom992

This comment has been minimized.

Copy link

atom992 commented Apr 26, 2016

we need resource-id information visible in order to test too.

@kahn004

This comment has been minimized.

Copy link

kahn004 commented Apr 27, 2016

Workaround:
Use both accessible and accessibleLabel on your views (so far, seems to work on View, Text, TextInput) and UiAutomator will generate content-desc field from accessibleLabel.

For now, we can use content-desc to identify tags.

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

Ideally, we should be able to test id's only with testId. But for now, it is what it is :(

@JumalDB

This comment has been minimized.

Copy link

JumalDB commented May 10, 2016

We need resource-id information visible for testing too. Is there any date when it will be implemented?

@talarari

This comment has been minimized.

Copy link

talarari commented Jun 26, 2016

Any update on this?

@sijicl

This comment has been minimized.

Copy link

sijicl commented Jun 29, 2016

Ping..Bothered by this issue as well. How does React Native community do end to end UI test on Android App without resource id supported here? Thanks.

@sondremare

This comment has been minimized.

Copy link

sondremare commented Jun 30, 2016

upvote

@tuckerconnelly

This comment has been minimized.

Copy link

tuckerconnelly commented Jul 13, 2016

Here's where the testID is set on android views:

Not the best with Android, but seems like you'd want to use setId() there instead of setTag(). That way, if you were using webdriverio, you could do something like:

var selector = 'new UiSelector().resourceId("whatever")';
browser.click('android=' + selector);

...I think?

I can get around to submitting a PR for this when I get to android automation.

Edit:

Alright, getting more familiar with Appium. Looks like in the BaseViewManager we'd want to use .setContentDescription(), and then you could access it on webdriverio like this:

client.element('~myTestID')
@tuckerconnelly

This comment has been minimized.

Copy link

tuckerconnelly commented Jul 14, 2016

@lexs Is there anything depending on the testID being in the tag? Would you accept a PR for this?

@mkonicek

This comment has been minimized.

Copy link
Contributor

mkonicek commented Jul 18, 2016

Commented on #8843, copying here:

We use the tag in our internal e2e testing system. contentDescription is used for accessibility: https://developer.android.com/training/accessibility/accessible-app.html

You could:

@mkonicek mkonicek closed this Jul 18, 2016

@jasonfma

This comment has been minimized.

Copy link

jasonfma commented Jul 18, 2016

Is it actually bad to set the resource-id as well as the tag? I would rather use resource-id than override the content description since it is used for accessibility. But of course tag does seem like the better option all around.

@mkonicek do you have an example of how to get the view by the tag in appium? I think we're all here because we're not sure how to do it. Thanks :)

@talarari

This comment has been minimized.

Copy link

talarari commented Jul 20, 2016

@jasonfma its not currently supported in appium
appium/appium#6025
Im using content description, how are you using resource id?

@talarari

This comment has been minimized.

Copy link

talarari commented Jul 24, 2016

any chance of setting resource-id in addition to content-desc?

would allow us to select the element in appium today, until they add support for selecting an element by view tag.

the current solution is kind of bad for accessibility because it forces us to set accessibility labels for controls that are not important for accessibility.

@jdeff

This comment has been minimized.

Copy link

jdeff commented Aug 30, 2016

@talarari if you want to set the resource-id on a view for automation, you probably want to do it on it's corresponding AccessibilityNodeInfo object. You can use setViewIdResourceName to set the appium-visible resource id for a view.

We do this whenever we need to dynamically set a resource id for UI automation with appium.

@jdeff

This comment has been minimized.

Copy link

jdeff commented Aug 30, 2016

Actually, looking at this a little more, this would be a very simple thing to add to AccessibilityHelper.java.

@jsdevel

This comment has been minimized.

Copy link
Contributor

jsdevel commented Sep 18, 2016

Hey all, I have a PR to add proper support for resource-id. Check it out and up-vote please: #9942

Once that's merged in testID will add resource-id so long as the Id is defined in res/values/ids.xml.

@forki

This comment has been minimized.

Copy link
Contributor

forki commented Jan 5, 2017

Once that's merged in testID will add resource-id

What's the status of this?
I'm using react native 0.40 and setting testID on an image doesn't seem to set the resource-id!?

@JanPeter

This comment has been minimized.

Copy link

JanPeter commented Apr 27, 2017

No update on this?

@gmaggess

This comment has been minimized.

Copy link

gmaggess commented Jul 12, 2017

I wonder if this has been forgotten by the react native team...

@tayunus

This comment has been minimized.

Copy link

tayunus commented Jul 25, 2017

we are suffering and they don't care...

the problem is that some people say that testID will add a tag to the element, but Appium doesn't support it.

some people say Appium cut the support for tag in version 1.5: i tried it and it didn't work in version 1.4.

some people are saying that tag will be activated in Appium version 2 because of uiautomator 2 (i think), but nothing new on that.

there is a tool called cavy, but it doesn't have support at all, it's a couple of months old....

i think the best thing we can do is to use accessibility label and add a special key in front of everything so that we can find and comment it thru out the whole application, i guess something like:

accessibilityLabel="ID button1"
accessibilityLabel="ID button2"
.
.
.
and then find (accessibilityLabel="ID) and replace it with (//accessibilityLabel="ID)

@WilliamNurmi

This comment has been minimized.

Copy link

WilliamNurmi commented Aug 18, 2017

upvote

@bhgames

This comment has been minimized.

Copy link

bhgames commented Jan 23, 2018

I got Android to work using accessibilityLabel, but on Sauce, where I have to use a release APK and not a debug APK which expects a package server to exist, it for some reason strips out accessibility labels in Android. So you can test Android, but God help you if you want to parallelize it on a third party. Only your laptop will do!

@Sartory

This comment has been minimized.

Copy link

Sartory commented Feb 6, 2018

@bhgames How did you manage to do this? I'm struggling to get it to run for two days now, but the appium test always fails with

[elementByAccessibilityId("testId-mainView-button1")] Error response status: 7, , NoSuchElement - An element could not be located on the page using the given search parameters. Selenium error: An element could not be located on the page using the given search parameters.

react-native code:
<View accessible={true} accessibleLabel="testId-index-view"> <Button accessibilityLabel="testId-mainView-button1" title="1" style={styles.button} onPress={() => this.handleButtonClick('1')} /> </View>
appium test:
await driver.elementByAccessibilityId('testId-mainView-button1').click();

In the Appium inspector I'm able to see the button's accessibilityLabel="testId-mainView-button1" and with "search for element" with "Locator Strategy:Accessibility ID - Selector:
testId-mainView-button1" in Appium I get the correct button.

iOS works if deleting the accessible={true} in the <View>

@bhgames

This comment has been minimized.

Copy link

bhgames commented Feb 6, 2018

So the issue was that CodePush was overwriting my newer labeled JS code with older nonlabeled code on SauceLabs since it was considered a release APK, and my labels worked locally because in debug mode, CodePush doesn't do that. That was my issue, but yours sounds different.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 18, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.