【发布时间】:2018-10-31 10:28:42
【问题描述】:
我第一次尝试编写单元测试用例。这是阻止以下情况。
当我点击一个按钮时,它会导航到下一个屏幕并加载 webview。我需要等待 webview 加载。
我试图等到下面的代码可以看到 staticTexts,
let rewards = self.app.staticTexts[“Rewards”]
let exists = NSPredicate(format: “exists == 1”)
expectationForPredicate(exists, evaluatedWithObject: rewards, handler: nil)
waitForExpectationsWithTimeout(10, handler: nil)
XCTAssert(rewards.exists)
XCTAssert(app.staticTexts[“Rewards Overview”].exists)
但在我的场景中,当我点击按钮时,它将导航到下一个屏幕,并且 webview 将开始加载。但 webview 内容始终是动态的。所以我需要等到 webviewDidFinishLoad。
【问题讨论】:
标签: ios swift xctest ios-ui-automation xctestcase