appium-desktop icon indicating copy to clipboard operation
appium-desktop copied to clipboard

Show 'id' and 'accessibility-id' even if not unique

Open pigeon56 opened this issue 8 years ago • 18 comments

Appium or Appium Desktop?

Appium Desktop

  • [ X ] I have verified that my issue does not occur with Appium and should be investigated as an Appium Desktop issue

The problem

I recently noticed that when I inspect elements in the app that I'm testing, the Accessibility Id that I expect to see is gone about 50% of the time. It is replaced by an xpath under "Find By", and the Accessibility Id exists instead as a "name" attribute. The developer did not make any changes to the Accessibility Ids. I tried running my automated test suite and all of my tests still pass without changing MobileBy.AccessibilityId to Attribute.getValue("name"). This is why I believe this issue is related to Appium Desktop - because I can still locate by Accessibility Id in my code even though it's not present in Appium Desktop.

Environment

  • I am running Appium Desktop version 1.2.0-beta.1.
  • I am on (pick one):
    • [ X ] Mac
    • [ ] Windows
    • [ ] Linux

pigeon56 avatar Aug 15 '17 14:08 pigeon56

Interesting. I think we base which strategy we recommend off of what we find in the source xml. I wonder if the xml is coming back with different values. Or @dpgraham do you have any ideas?

@ChiWhiteSox56 you are working with iOS I assume?

jlipps avatar Aug 15 '17 15:08 jlipps

@jlipps - Correct. I am working with iOS. Simulator is on 10.3.1 to be exact.

pigeon56 avatar Aug 15 '17 16:08 pigeon56

image I seem to be getting the same thing. Not for all cells, but these cells have accessibilityIDs and yet are showing name only.

travstatham avatar Aug 16 '17 19:08 travstatham

@dem0n0cracy - Yep. Same issue. Thank you for posting a screenshot - I didn't think to do that.

pigeon56 avatar Aug 16 '17 19:08 pigeon56

image Meanwhile, other cells have the correct a_id

travstatham avatar Aug 16 '17 20:08 travstatham

Are the accessibility ID's unique? One of the changes we made was to check in the source XML to verify that the selector was unique and if it wasn't, don't show it in the 'find By' chart.

@dem0n0cracy or @ChiWhiteSox56 can one of you either share your source XML or check the source XML to verify that there aren't multiple nodes with the same accessibility ID?

dpgraham avatar Aug 17 '17 17:08 dpgraham

Sorry for the delayed response. I'll grab the source XML, but I can tell you right now that the Accessibility Ids in my app are not unique for all places. Example: In a list, each "cell" has the same Accessibility Id, but a unique label. This is by design so I can easily iterate through them and locate the item I want by its label. So in some cases, there are many items on a page with the same Accessibility Id.

Edit: typo

pigeon56 avatar Aug 21 '17 20:08 pigeon56

@ChiWhiteSox56 ah that makes sense. So if an accessibility id is not unique, we're not going to recommend it as a way to find an element, since it might not find that particular element. But you can still see it in the list of attributes of the element, even though it's not "recommended" for that reason.

jlipps avatar Aug 21 '17 20:08 jlipps

@jlipps Ah, okay. I see what you mean. I do see the accessibility id in the attributes of the element, but it seems it's called "name" instead of "accessibility id" when the accessibility ids are not unique.

pigeon56 avatar Aug 21 '17 21:08 pigeon56

right, that part we could probably fix. the thing is it's called 'name' by ios, even when it's also the accessibility id :-)

jlipps avatar Aug 21 '17 23:08 jlipps

The reason we don't show it if it's not unique is because when you do a findElement on a non-unique accessibility id it may find the wrong element.

What we could do is if it's not unique, put an asterisk besides it indicating that it's not unique.

dpgraham avatar Aug 22 '17 16:08 dpgraham

I just introduced a bug into my app and had this problem again, and realized I had the same ID for two different cells. So yes, you guys are correct.

travstatham avatar Sep 13 '17 19:09 travstatham

thanks for letting us know @dem0n0cracy

jlipps avatar Sep 13 '17 20:09 jlipps

@jlipps I am also facing the same issue. Accessibility id is missing if not unique. Why name property and accessibility id have same value?

viccky88 avatar May 29 '18 13:05 viccky88

When i use xpath as : driver.findElement(By.xpath("//*[@accessibility id='Continue']")).click();

it is giving me an error No such element exception. Please let me know what is wrong in xpath.

kavyavangala avatar Jun 21 '18 10:06 kavyavangala

When i use xpath as : driver.findElement(By.xpath("//*[@accessibility id='Continue']")).click();

it is giving me an error No such element exception. Please let me know what is wrong in xpath.

Is the above attribute missing a "-" @kavyavangala ? Try "@accessibility-id"

alexandlazaris avatar Jun 25 '19 23:06 alexandlazaris

accessibility-id"

This is also not working, have you tried at your side?

ankitguptatest avatar Nov 04 '19 06:11 ankitguptatest

I can't remember off the top of my head. I might even use @id. Also try changing By.xpath to By.id? Also if you're using java https://appium.github.io/java-client/io/appium/java_client/FindsByAccessibilityId.html

accessibility-id"

This is also not working, have you tried at your side?

I can't remember off the top of my head. I might even use @id. Also try changing By.xpath to By.id? Also if you're using java https://appium.github.io/java-client/io/appium/java_client/FindsByAccessibilityId.html

alexandlazaris avatar Nov 26 '19 13:11 alexandlazaris