加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iOS UITesting:使用addUIInterruptionMonitorWithDescription自

发布时间:2020-12-14 17:47:28 所属栏目:百科 来源:网络整理
导读:我已经读完了这两个. Xcode7 | Xcode UI Tests | How to handle location service alert? Xcode 7 UI Testing: Dismiss Push and Location alerts 我能知道以下情况吗? 1)对于位置,放置“位置对话框”表示它将处理位置提示.它如何识别? 2)如何处理访问图库
我已经读完了这两个.

Xcode7 | Xcode UI Tests | How to handle location service alert?

Xcode 7 UI Testing: Dismiss Push and Location alerts

我能知道以下情况吗?

1)对于位置,放置“位置对话框”表示它将处理位置提示.它如何识别?

2)如何处理访问图库或相机的系统提示?是否有任何处理程序描述列表?

解决方法

这里是addUIInterruptionMonitorWithDescription的xcode文档.

/*! Adds a handler to the current context. Returns a token that can be used to unregister the handler. Handlers are invoked in the reverse order in which they are added until one of the handlers returns true,indicating that it has handled the alert.
     @param handlerDescription Explanation of the behavior and purpose of this handler,mainly used for debugging and analysis.
     @param handler Handler block for asynchronous UI such as alerts and other dialogs. Handlers should return true if they handled the UI,false if they did not. The handler is passed an XCUIElement representing the top level UI element for the alert.
     */
    public func addUIInterruptionMonitorWithDescription(handlerDescription: String,handler: (XCUIElement) -> Bool) -> NSObjectProtocol

1)“位置对话框”只是一个处理程序描述,用于标识您处理的警报.你可以写别的东西.

2)你必须使用相同的方法.只需点按应用后即可.

在这里,我使用这部分代码来处理推送通知:

addUIInterruptionMonitorWithDescription("Push notifications") { (alert) -> Bool in
       if alert.buttons["OK"].exists {
            alert.buttons["OK"].tap()
            return true
       }
       return false
}
app.tap()

干杯

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读