Search code examples
xcodeswiftios9ui-testing

Xcode 7 UI test loop through all switches


Is there a possibility to test all the switches that are present in the app.tables.switches dictionary. When I record the test the line get added with a string as key like:

app.tables.switches["Kantoor, kntr"].tap()

But I'd like to loop trough all the switches with a for-loop like (code doesn't work):

for index in 0...app.tables.switches.count {
    XCTAssertTrue(app.tables.switches[index].value, "")
}

This is a check to verify if all the switches of every row is enabled/disabled after I clicked the "disable all"-button.


Solution

  • I finally found the solution, it's way simpler than I expected but used the wrong approach. This fix is to use te following command:

    let firstSwitch = app.tables.switches.elementBoundByIndex(0)