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.
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.
Share Improve this question edited Mar 31 at 17:33 jwallis asked Mar 31 at 17:27 jwallisjwallis 951 silver badge9 bronze badges1 Answer
Reset to default 0KazuCocoa pointed me to the documentation, which makes it clear:
https://appium.github.io/appium-xcuitest-driver/latest/reference/locator-strategies/
name, accessibility id : These locator types are synonyms and internally get transformed into search by element's name attribute for IOS