Element locator difference between iOS and Android

Hi!

Maybe someone can help me understand why on iOS and Android the locators strategy act differently.

Let’s say I have an element with this attributes on Android:

accessibility id - Login_LogoImage
id - com.scr.sensetime:id/icon_layout
content-desc - Login_LogoImage
resource-id - com.scr.sensetime:id/icon_layout
And on iOS the element has this attributes:
accessibility id - Login_LogoImage
name - Login_LogoImage

I’m trying to understand why when I use ID locator strategy on iOS it finds the element while on android it’s not?
How does appium interpreter this attributes on each platform?

write your code. it helps better to understand

It’s not really related to my code. I’m talking about the issue or the design appearing already on the appium inspector level. Is this true the appium treat the accessibility id as ID on ios but on android it’s not?

For iOS, the default Accessibility ID is set to the name of the UI element. For Android, the value of Accessibility is same as the value of the attribute “content-desc”.

I understand that fact, but it’s still not clear to me why, on iOS, the Appium can locate the element with an ID locator using the accessibility ID value.

                                  iOS              Android
AppiumBy.id                       name           resource-id
AppiumBy.accessibilityId          name           content-descr
2 Likes