最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin8浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论