簡體   English   中英

iOS UITests-XCUIElements標識符的作用是什么

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM