I've come across a weird issue with swift xcuitest regarding switches in my tests. I'm testing settings app, to check if certain switches are on. I'm fairly new to swift but from resources I've read I've found I should do something like the following:
let mySwitch = settingsApp.switches["Block Pop-ups"]
XCTAssert(mySwitch.exists)
let isOn = (mySwitch.value as? String).map { $0 == "1" }
XCTAssert(isOn == true)
However when testing for simulators on ios 12, I've found the value for the switch always seems to have nil value whether is on or off e.g. both assertions below are false
XCTAssertFalse(isOn == true)
XCTAssertFalse(isOn == false)
I found this on apple forums but there is no answer posted. Does anyone have a fix or workaround for this?
I'm using swift 5.1, and xcode 11
Edit: need a solution for iOS 12, I am not in a position to upgrade to 13
