有没有办法强制机器人在xcode持续集成中的ui测试下始终接受权限警报?

Bar*_*zyk 2 xcode continuous-integration xcode-ui-testing

我需要使用大量的模拟器在xcode服务器上运行持续集成.有没有办法强制它始终接受权限警报,如:

允许"App"访问您的照片

等等...

Ole*_*tha 8

在您的setUp()方法中,创建中断监视器并通过单击"确定"按钮来处理警报.这意味着每当您尝试与应用程序进行交互时,都会进行检查以查看权限视图是否妨碍,然后点击"确定"按钮.

let permissionInterruptionMonitor = addUIInterruptionMonitor(withDescription: "Photos permission alert") { (alert) in
    alert.buttons["OK"].tap()
    return true // The interruption has been handled
}
Run Code Online (Sandbox Code Playgroud)

如果您的应用程序中可能出现其他警报,但是您不希望自动处理这些警报,但您应该确保中断监视器处理程序检查它是您要处理的警报.

let permissionInterruptionMonitor = addUIInterruptionMonitor(withDescription: "Photos permission alert") { (alert) in
    if alert.staticTexts["\"AppName\" Would Like To Access Your Photos"].exists {
        alert.buttons["OK"].tap()
        return true // The interruption has been handled
    }
    return false // The interruption has not been handled
}
Run Code Online (Sandbox Code Playgroud)