在我的iOS应用程序中,我添加了UI测试,我需要检查导航栏按钮是否在不同的时间启用/禁用.
目前我正在使用:
XCUIElement* saveButton = self.app.navigationBars[@"TSSIDAddCardView"].buttons[@"Save"]; XCTAssertEqual(saveButton.hittable,YES);
但是,这始终返回YES. .exists测试也返回YES.
有谁知道如何进行正确的测试?
解决方法
您可以通过value属性获取实际的UI组件.
有了它,您可以检查它是否已启用.
就像是:
UIBarButtonItem *saveButton = self.app.navigationBars[@"TSSIDAddCardView"].buttons[@"Save"].value; XCTAssertTrue(saveButton.enabled);