Naming differences
There are some naming differences that add to the confusion when comparing Appium, Android, and iOS terminology. Specifically, when using AppiumBy.ID
and AppiumBy.ACCESSIBILITY_ID
.
To help with understanding, it is useful to use Appium Inspector to visualize the differences.
Appium Inspector displays two useful sections on the right-hand side, Find By and Attribute.
- Find By shows (some) locator strategies you could use to find the selected element, and the value it returns
- Attribute provides information on the element's properties, and their corresponding values
AppiumBy.ID
When locating an element using AppiumBy.ID, Appium looks for the following atributes:
resource-id
(Android)name
(iOS)
AppiumBy.ACCESSIBILITY_ID
When locating an element using AppiumBy.ACCESSIBILITY_ID, Appium looks for the following attributes:
content-desc
(Android)name
(iOS)
Appium Inspector
When inspecting the app with Appium Inspector you see the available strategies shown in the Find By section, and element attributes in the Attribute section.
Find By
For Android
id
shows the value ofresource-id
accessibility id
shows the value ofcontent-desc
For iOS
accessibility id
shows the value ofname
Attribute
For Android
resource-id
shows the value ofResource ID
content-desc
shows the value ofContentDescription
For iOS
name
shows the value ofaccessibilityIdentifier
(oraccessibilityLabel
ifaccessibilityIdentifier
is not set)label
shows the value ofaccessibilityLabel
Table: Locator strategies in Appium Inspector
The table below shows different locator strategies used in Appium, and corresponding attributes shown in Appium Inspector.
Appium Inspector | Android | iOS |
---|---|---|
id | resource-id | name |
accessibility id | content-desc | name |
Table: Element attributes in Appium Inspector
The table below shows different element attributes used by Appium, and corresponding properties that are set on mobile platforms.
Appium Inspector | Android | iOS |
---|---|---|
resource-id | Resource ID | |
content-desc | ContentDescription | |
name | accessibilityLabel / accessibilityIdentifier | |
label | accessibilityLabel |
Note:
- accessibilityLabel is used by screen readers and should be written in a user-friendly manner
- accessibilityIdentifier should use a different format to avoid confusion and retain uniqueness
Additional resources
Check Mobile - element IDs for info on how to set the element ID.