Post

Replies

Boosts

Views

Activity

Reply to Switch value on XCUITest in Settings app not working anymore with Xcode 11
Also ran into this very strange bug, also only on iOS 12.x. I found a workaround I've not seen posted here or on https://stackoverflow.com/questions/62413398/xcuitest-ios-12-switch-element-value-is-on when I was frustrated and searching for a solution. It seems this issue appears only when referencing the switch element using the array style format. You can workaround by instead using the matching method of the XCUIElementQuery and - at least in my testing - the bug will not appear. Here's the workaround applied to the original example: let switchPredicate = NSPredicate(format:"(label MATCHES[c] %@)", "Sounds") let switchSounds = settingsApp.switches.matching(switchPredicate).firstMatch let expectedValue = isEnabled ? "1" : "0" XCTAssert(switchSounds.value as? String == expectedValue)
May ’23