如何在 UITest 中允许跟踪?

问题描述

我已尝试调用“addUIInterruptionMonitor”以获取应用跟踪透明度通知,但它没有注册并且在我的下一步中失败。任何有关此对话框描述的帮助都会有所帮助,“系统对话框”不起作用。

“允许……在其他公司的应用和网站上跟踪您的活动”“要求应用不要跟踪”“允许”

addUIInterruptionMonitor(withDescription: "System dialog") {
        (alert) -> Bool in
        if alert.buttons["Cancel"].exists {
            alert.buttons["Cancel"].tap()
            self.app.activate()
            return true
        }
        
        return false
    }

Allow ... to track your activity across other companies' apps and websites

解决方法

找到解决方案,我使用的描述是“跟踪使用权限警报”

等待按钮出现的测试本身也是一个问题,该按钮仅在回答此对话框后才会出现

addUIInterruptionMonitor(withDescription: "Tracking Usage Permission Alert") {
        (alert) -> Bool in
        if alert.buttons["Allow"].exists {
            alert.buttons["Allow"].tap()
            self.app.activate()
            return true
        }
        return false    
    }

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...