iOS UITests - XCUIElements 标识符的用途
iOS UITests - What purpose XCUIElements identifier serves
在 iOS UITests 上工作时,我发现 XCUIElement has a property, identifier, which was confronted from XCUIElementAttributes. When I debug, I found this is a real-only property and always contains empty string. Can anyone explain what purpose this property serves? I am unable to get any distinguishing property between two 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
属性还没有在view上设置
在 iOS UITests 上工作时,我发现 XCUIElement has a property, identifier, which was confronted from XCUIElementAttributes. When I debug, I found this is a real-only property and always contains empty string. Can anyone explain what purpose this property serves? I am unable to get any distinguishing property between two 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
属性还没有在view上设置