首页 > 解决方案 > 如何允许在 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
    }

允许 ... 跟踪您在其他公司的应用程序和网站上的活动

标签: swifttrackingxcode-ui-testingxcuitestapptrackingtransparency

解决方案


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

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

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    
    }

推荐阅读