Reputation: 40196
While woking on iOS UITests, I found 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
I cannot change the identifier, its immutable.
Upvotes: 0
Views: 720
Reputation: 7649
The identifier
property of an XCUIElement is the same as the accessibility identifier of the UIView it represents.
// app code
let someButton: UIButton!
someButton.accessibilityIdentifier = "myIdentifer"
// test code
let button = XCUIApplication().buttons["myIdentifier"] // get XCUIElement for the button
print(button.identifier) // => "myIdentifier"
If the identifier
is empty, this is because the accessibilityIdentifier
property has not been set on the view.
Upvotes: 1