Eugene Zhenya Gordin Eugene Zhenya Gordin - 4 months ago 14
iOS Question

How to test if navigationBar button is enabled/disabled in UI test on iOS?

In my iOS app I've added UI tests, where I need to check if navigationBar button is enabled/disabled at different point of time.

Currently I'm using:

XCUIElement* saveButton = self.app.navigationBars[@"TSSIDAddCardView"].buttons[@"Save"];


XCTAssertEqual(saveButton.hittable, YES);


However, this always returns YES. The .exists test returns YES as well.

Does anyone knows how to do the proper test?

Answer

So with help of @InsertWittyName I found the solution:

UIBarButtonItem *saveButton = self.app.navigationBars[@"TSSIDAddCardView"].buttons[@"Save"];
XCTAssertFalse(saveButton.enabled);
Comments