javascript - 如何在 iOS uiautomation 中使用两个按钮处理警报

标签 javascript iphone ipad ios-ui-automation

我正在尝试从应用程序注销。当我单击“注销”时,它会显示一个警告框 -> 其中有两个按钮"is"和“取消”,但我无法单击"is"按钮.我尝试了以下代码:

    var log_out = mainWindow.popover().tableViews()[0].cells()["Log out of App"];
    log_out.tap();

    UIATarget.onAlert = function onAlert(alert){   
          var name = alert.name();
          UIALogger.logMessage("alert "+name+" encountered");
          if(name == "App") 
          {
              alert.buttons()["Yes"].tap();
              return true;
          } else {
              return false;
          }
      }

但是代码甚至没有进入警报函数,因为它没有打印任何消息“警报应用程序遇到”。点击“退出应用程序”按钮后脚本结束。我已经浏览过这些链接 - How to handle an iPhone alert with 2 buttons (want to click the non default button)how to select which button to select in alert message for IOS UIAutomation 但似乎不起作用,因为它无法进入警报,因为它没有通过 logMessage 打印任何消息,因此也无法使用坐标方法。

最佳答案

您可以尝试之前定义您的 onAlert 事件。

UIATarget.onAlert = function onAlert(alert){/代码/}

log_out.tap();

关于javascript - 如何在 iOS uiautomation 中使用两个按钮处理警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17651049/

相关文章:

javascript - HTML 头文件,改变按钮状态

iphone - Xcode 中的 Segue 头痛

ipad - 使用 modalInPopover 显示弹出框时如何禁用主工具栏?

iphone - 点击取消按钮时,移除 UISearchBar 右侧的清除按钮(灰色 x)

iphone - 如何在 UIAlertView 中制作文本字段 "become first responder"

iphone - ipad/iphone 应用程序的最佳方法

javascript - knockout : how to validate object observale

javascript - 第二个动画圆圈的颜色变化

javascript - 如何使用 express js 创建一个简单的 html 服务器

iPhone 4 为元素添加黄色条纹