当“警报”为"is"和“否”按钮时,如何单击警报消息按钮。

我尝试过这样的方式:

target.frontMostApp().alert().buttons()["buttonName"].tap();
target.frontMostApp().alert().buttons()["index"].tap();

Ui Automation还会单击任一按钮,并将以下语法显示为:
target.frontMostApp().alert().cancelButtons().tap();

当我手动单击默认按钮时它没有起作用,并且还尝试了以下方法。
target.frontMostApp().alert().cancelButtons()["index/buttonname"].tap();
target.frontMostApp().alert().defaultButtons()["index/buttonname"].tap();

如何从警报消息中选择是按钮或否按钮?

最佳答案

嗯,您需要在onAlert中使用此代码。

另外,您还需要在try catch块中再次点击。

我的代码用于删除表中的行并确认删除按钮上显示的警报。

target.frontMostApp().mainWindow() .tableViews()["Empty list"].cells()[0]
  .dragInsideWithOptions({startOffset:{x:0.03, y:0.44},
  endOffset:{x:0.81, y:0.50},duration:1});

target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()[0]
  .buttons()[0].tap();


UIATarget.onAlert = function onAlert(alert) {
    alert.tapWithOptions({tapOffset:{x:0.73, y:0.72}});
}

try {
    target.frontMostApp().alert().tapWithOptions({tapOffset:{x:0.72, y:0.78}});
}
catch (ex) {}

关于ui-automation - 如何在IOS UIAutomation的警报消息中选择要选择的按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13172937/

10-14 11:21
查看更多