appiumxcuitest

Appium XCUITest: what is ACCESSIBILITY_ID really? It's not in the page source, but it works locating an element


Swift code:

.automationIdentifier(.developer, .toggle, .custom("Notification Permission"))

Page source: Clearly something is concatenating the attributes in the swift code into the element's name. Cool, hopefully it will be unique.

<XCUIElementTypeStaticText name="developer_toggle_custom_notificationpermission" value="Push Notification Permission" label="Push Notification Permission" ...

Appium inspector: shows the same info as page source, and does NOT show anything for "accessibility id"

Finding the element: To my surprise, using ACCESSIBILITY_ID works!

d.find_element(AppiumBy.ACCESSIBILITY_ID, 'developer_toggle_custom_notificationpermission')
<appium.webdriver.webelement.WebElement (session="48177c66-2837-4b66-9bd9-6e8bab1ff77b", element="E6000000-0000-0000-AE9F-000000000000")>

So it seems to me that ACCESSIBILITY_ID is a "soft" attribute. It is not a "hard" attribute like name, size, visible... It seems there are rules around calling something an ACCESSIBILITY_ID, possibly something like "if an element's name exists and is unique in the page source, consider it an ACCESSIBILITY_ID"

I'm guessing this would take an Appium developer to answer. Insight is appreciated.


Solution

  • KazuCocoa pointed me to the documentation, which makes it clear:

    https://appium.github.io/appium-xcuitest-driver/latest/reference/locator-strategies/

    nameaccessibility id : These locator types are synonyms and internally get transformed into search by element's name attribute for IOS