我有一个启动画面,显示3秒钟,然后淡入新视图。在这种观点中,有UILabel
被称为"隐私政策"我附加了UIGestureRecognizer
。我尝试使用UI测试来点击该标签以触发导航控制器推送。这在现实生活中有效,但是,在UI测试期间,水龙头不做任何事情。我的代码如下所示:
func testPrivacyPolicyLink() {
let app = XCUIApplication()
let exists = NSPredicate(format: "exists == 1")
expectationForPredicate(exists, evaluatedWithObject: app.images["Logo"], handler: nil)
waitForExpectationsWithTimeout(5) { error in
XCTAssertNil(error, "Splash screen took too long")
sleep(4) // Added this just to make sure the splash screen has fully faded away
app.staticTexts["Privacy Policy"].tap() // Should trigger a navigation controller push, but doesn't do anything
}
}
即使在为这种情况录制UI测试时,它也会调用app.staticTexts["Privacy Policy"].tap()
。但是当我回放它时,它并没有起作用。任何有关这方面的帮助将不胜感激!
答案 0 :(得分:2)