[英]iOS UITests - What purpose XCUIElements identifier serves
在iOS UITests上啟動時,我發現XCUIElement具有一個屬性identifier ,這是XCUIElementAttributes遇到的 。 調試時,我發現這是一個只讀屬性,並且始終包含空字符串。 誰能解釋這個屬性的目的是什么? 我無法獲得兩個XCUIElement之間的任何區別屬性
我無法更改標識符,它是不可變的。
XCUIElement的identifier
屬性與其表示的UIView的可訪問性標識符相同。
// app code
let someButton: UIButton!
someButton.accessibilityIdentifier = "myIdentifer"
// test code
let button = XCUIApplication().buttons["myIdentifier"] // get XCUIElement for the button
print(button.identifier) // => "myIdentifier"
如果identifier
為空,這是因為尚未在視圖上設置accessibilityIdentifier
屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.