appium-desktop
appium-desktop copied to clipboard
Show 'id' and 'accessibility-id' even if not unique
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
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 - Correct. I am working with iOS. Simulator is on 10.3.1 to be exact.
I seem to be getting the same thing. Not for all cells, but these cells have accessibilityIDs and yet are showing name only.
@dem0n0cracy - Yep. Same issue. Thank you for posting a screenshot - I didn't think to do that.
Meanwhile, other cells have the correct a_id
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?
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
@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 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.
right, that part we could probably fix. the thing is it's called 'name' by ios, even when it's also the accessibility id :-)
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.
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.
thanks for letting us know @dem0n0cracy
@jlipps I am also facing the same issue. Accessibility id is missing if not unique. Why name property and accessibility id have same value?
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.
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"
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
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