2
我有一個啓動屏幕,顯示3秒鐘,然後淡入新視圖。在這個觀點上,有一個叫做「隱私政策」的UILabel
,我附上了UIGestureRecognizer
。我正在嘗試使用UI測試來點擊該標籤來觸發導航控制器。這在現實生活中可行,但是,在UI測試期間,水龍頭不會做任何事情。我的代碼如下所示:UI測試tap()不起作用
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()
其中工程。但是當我回放時,它不起作用。任何幫助,將不勝感激!
爲什麼不使它成爲一個按鈕? –
@LukePatterson這很複雜......但這應該不重要? – Tometoyou
如果它在現實生活中有效,爲什麼你需要測試它? – user2277872