如何在 IOS UIAutomation 的警报消息中选择要选择的按钮 [英] how to select which button to select in alert message for IOS UIAutomation

查看:26
本文介绍了如何在 IOS UIAutomation 的警报消息中选择要选择的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当警报有是和否按钮时如何点击警报消息按钮.

How to click on alert message buttons when Alert has Yes and No Buttons.

我试过这样的方法:

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

还有 Ui 自动化点击任一按钮并显示以下语法:

And also Ui Automation click on either of the button and displays the below syn tax as:

target.frontMostApp().alert().cancelButtons().tap();

当我手动点击默认按钮时它不起作用.还尝试了以下方法.

and its didnt work when i do it manually to click on default button.and also tried with the below ways also.

target.frontMostApp().alert().cancelButtons()["index/buttonname"].tap();
target.frontMostApp().alert().defaultButtons()["index/buttonname"].tap();

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

How to select the Yes button or NO button from the Alert message?

推荐答案

啊,您需要在 onAlert 中使用此代码.

Ahhh you need to use this code inside an onAlert.

您还需要在 try catch 块中再次点击.

Also you need to a second tap in a try catch block.

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

My code where is used to delete a row in a table and confirm an alert shown on the delete button.

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) {}

这篇关于如何在 IOS UIAutomation 的警报消息中选择要选择的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆