Reputation: 3981
I want to figure out which segment is selected on a segmented control in Xcode's new UI Testing in Swift.
I can get the segmentedControl XCUIElement, and the 'buttons' associated with it, but I'm not sure how to test for the selected property.
Sorry in advance if this is something obvious that I have missed.
Upvotes: 16
Views: 5716
Reputation: 1245
Version for Swift 4:
let environment = app.segmentedControls.element(boundBy: 0);
XCTAssertTrue(environment.buttons.element(boundBy:0).isSelected, "Wrong environment selected");
Upvotes: 3
Reputation: 376
XCUIElement
has a selected
property which you can examine:
XCTAssertTrue(app.segmentedControls.buttons.elementBoundByIndex(0).selected)
Upvotes: 22