Tag: Uitests

在iOS UITests中处理警报

通常,在应用程序中,您需要使用需要打开推送通知和位置权限的步骤来启动。 您想通过UITests自动执行这些步骤 首先,您需要添加interruption handler addUIInterruptionMonitor(withDescription:“ Alert”){ 元素在 做{ // 推送通知 让按钮= element.buttons [“允许”] let title = element.staticTexts [““ MyAwesomeApp”将向您发送通知”] 如果title.exists && button.exists { button.tap() } }做{ // 位置 let button = element.buttons [“仅在使用应用程序时”] 如果button.exists { button.tap() } 返回true } } 然后您需要在XCUIApplication上调用tap以使应用程序响应 turnOnPushNotificationButton.tap() 点击() 有时,警报处理速度很慢,并且您Did not receive view did disappear notification within 2.0s 。 好了,解决方法是等待下一个入门步骤中的元素出现。 从Xcode […]