storyboard
.the Utilities
Identity Inspector
addButton
)storyboard
.the Utilities
Identity Inspector
User Defined Runtime Attributes
Key Path
type - accessibilityIdentifier
Type
- `StringValue
- new accessibility identifier for your element (in example view
)import XCTest class StackOverFlowUITests: XCTestCase { private let app = XCUIApplication() //Views private var view: XCUIElement! //Buttons private var addButton: XCUIElement! override func setUp() { super.setUp() app.launch() //Views view = app.otherElements["view"] //Buttons addButton = app.buttons["addButton"] } func testMyApp() { addButton.tap() view.tap() } }
In [ ]
add Accessibility Identifier for element.
let imageView = app.images["imageView"] let scrollView = app.scrollViews["scrollView"] let view = app.otherElements["view"]
let label = app.staticTexts["label"]
let stackView = app.otherElements["stackView"]
let tableView = app.tables["tableView"]
let tableViewCell = tableView.cells["tableViewCell"]
let tableViewCellButton = tableView.cells.element(boundBy: 0).buttons["button"]
let collectionView = app.collectionViews["collectionView"]
let button = app.buttons["button"] let barButtonItem = app.buttons["barButtonItem"]
let textField = app.textFields["textField"]
let passwordTextField = app.secureTextFields["passwordTextField"]
let textView = app.textViews["textView"]
let switch = app.switches["switch"]
let alert = app.alerts["About yourself"] // Title of presented alert