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

ios – Xcode UITest推送通知提醒无法点击“允许”

发布时间:2020-12-14 18:04:52 所属栏目:百科 来源:网络整理
导读:有没有人有类似的情况?因此,应用程序打开,推送通知警报显示询问用户是否允许接收推送通知,测试单击“不允许”,即使我有以下代码: func testClickSystemAlert(){ let app = XCUIApplication(); XCUIApplication().alerts["“纳豆行” Would Like to Send Yo
有没有人有类似的情况?因此,应用程序打开,推送通知警报显示询问用户是否允许接收推送通知,测试单击“不允许”,即使我有以下代码:

func testClickSystemAlert(){
        let app = XCUIApplication();
        XCUIApplication().alerts["“纳豆行” Would Like to Send You Notifications"].buttons["Allow"].tap()
    }

这是print的输出(XCUIApplication().debugDescription);

Attributes: Application 0x60000016c540: {{0.0,0.0},{414.0,736.0}},label: '纳豆行'
Element subtree:
 →Application 0x60000016c540: {{0.0,label: '纳豆行'
    Window 0x60000016bc40: Main Window,{{0.0,736.0}}
      Other 0x60000016c780: {{0.0,736.0}}
        Other 0x60000016c9c0: traits: 8589934592,736.0}}
          ScrollView 0x60000016bf40: traits: 8589934592,736.0}}
            Image 0x60000016c0c0: traits: 8589934596,identifier: '1'
          PageIndicator 0x600000163000: traits: 8589939200,{{132.0,691.0},{150.0,55.0}},value: page 1 of 4
    Window 0x6000001693c0: {{0.0,736.0}}
      StatusBar 0x600000169240: {{0.0,20.0}}
        Other 0x60000016ca80: {{0.0,20.0}}
        Other 0x60000016cb40: {{0.0,20.0}}
          Other 0x60000016cc00: traits: 8388608,{{6.0,{39.0,20.0}}
          Other 0x60000016ccc0: traits: 8388608,{{50.0,{13.0,20.0}},label: '3 of 3 Wi-Fi bars',value: SSID
          Other 0x60000016cd80: traits: 8389120,{{181.0,{56.0,label: '12:29 AM'
          Other 0x60000016ce40: traits: 8388608,{{384.0,{25.0,label: '-100% battery power'
Path to element:
 →Application 0x60000016c540: {{0.0,label: '纳豆行'
Query chain:
 →Find: Target Application 0x6000000b7340
  Output: {
    Application 0x60000016c540: {{0.0,label: '纳豆行'
  }

解决方法

我最终使用这个:

addUIInterruptionMonitor(withDescription: "Allow push") { (alerts) -> Bool in
            if(alerts.buttons["Allow"].exists){
                alerts.buttons["Allow"].tap();
            }
            return true;
        }

它将单击“允许”按钮

(编辑:李大同)

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

    推荐文章
      热点阅读