iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – Xcode UITest推送通知提醒无法点击“允许”大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

有没有人有类似的情况?因此,应用程序打开,推送通知警报显示询问用户是否允许接收推送通知,测试单击“不允许”,即使我有以下代码: func TESTClickSystemAlert(){ let app = XCUIApplication(); XCUIApplication().alerts["“纳豆行” Would Like to Send You Notific
@H_772_13@
有没有人有类似的情况?因此,应用程序打开,推送通知警报显示询问用户是否允许接收推送通知,测试单击“不允许”,即使我有以下代码

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;
        }

它将单击“允许”按钮

大佬总结

以上是大佬教程为你收集整理的ios – Xcode UITest推送通知提醒无法点击“允许”全部内容,希望文章能够帮你解决ios – Xcode UITest推送通知提醒无法点击“允许”所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。