Reputation: 10012
I've been able to find the following KIF method for setting the value of a UISwitch
:
tester.setOn(false, forSwitchWithAccessibilityLabel: "Enable Feature")
However, I have been unable to figure out how to retrieve the value of a UISwitch, using KIF, in an assert/test approach.
Any ideas?
Upvotes: 4
Views: 898
Reputation: 1487
The waitForViewWithAccessibilityLabel
returns a view. So how about this?
let view = tester().waitForViewWithAccessibilityLabel("Enable Feature")
let switchView = view as? UISwitch
XCTAssertNotNil(switchView)
XCTAssertTrue(switchView!.on) // or XCTAssertFalse(switchView!.on)
Upvotes: 3
Reputation: 10012
I figured it out:
To test for switch on:
tester.waitForViewWithAccessibilityLabel("Enable Feature", value: "1", traits: UIAccessibilityTraitNone)
To test for switch off:
tester.waitForViewWithAccessibilityLabel("Enable Feature", value: "0", traits: UIAccessibilityTraitNone)
Upvotes: 2