【发布时间】:2018-07-03 03:58:58
【问题描述】:
我正在为我的项目编写 UI 测试用例。
我的项目流程如下:
- 登录屏幕。用户输入凭据并按登录。
- 主屏幕。有位置要求,因此系统为用户许可。我允许。
- 退出。
因此,当我重新安装应用程序时,此流程会记录在测试用例中,并且如果我在新的全新构建上执行,则可以工作。
但问题是当我在旧版本上进行测试时,没有位置许可警报并且测试失败。 如何处理这种情况或每次运行测试时都向用户征求许可?
为了重置用户的凭据,我将 launchArguments 传递给 XCUIApplication() 并在 AppDelegate 中处理。
我已经实现了代码让我知道它是否正确:
addUIInterruptionMonitor(withDescription: "Allow “APP” to access your location?") { (alert) -> Bool in
alert.buttons["Only While Using the App"].tap()
return true
}
上面的代码不管有没有警报都适用。
【问题讨论】:
标签: ios xcode xctest xcode-ui-testing ui-testing