如何使用2个按钮处理一个iPhone警报(需要单击非默认按钮) [英] How to handle an iPhone alert with 2 buttons (want to click the non default button)
问题描述
虽然我在键入邮件ID来我自动化的iPhone的参加办法结果:字段,然后点击发送,我得到两个按钮结果取消的确认警报和放大器; 发送。结果
默认的按钮是取消。我无法点击发送按钮。结果这里是我已经使用了code片段。请帮我这个
I am automating an iPhone appplication
While I type the mail ID in the TO: field and click on send, I get a confirmation alert with two buttons
"Cancel" & "Send".
The default button is "cancel". I'm unable to click on the send button.
Here is the code snippet which I have used. Please help me with this
//获取手柄
window = UIATarget.localTarget().frontMostApp().mainWindow();
target = UIATarget.localTarget();
app = target.frontMostApp();
buttons = window.buttons();
target.delay(2);
//点击导航栏上的发送按钮
//tap the send button on the navigation bar
app.navigationBar().buttons()["Send"].tap();
target.delay(2);
//警示处理程序
//Alert handler
UIATarget.onAlert = function onAlert(alert)
{
//Unable to enter this portion of the code
target.delay(2);
var alerttitle = alert.name();
UIALogger.logMessage("Alert with title: '"+alerttitle+"' encountered! ");
}
该控制并非处理器内部发生的。
The control is not going inside the handler at all.
推荐答案
有是围绕我想一个临时的工作是不是最好的方法,但可以保持过程向前发展
There is a temporary work around which I suppose is not the best approach, but can keep the process going forward
解决方法:挖掘发送按钮,使用相对按钮的近似坐标到屏幕上
Solution: to tap on the "Send" button using the approximate coordinates of the button relative to the screen.
我用下面的方式来实现这一点。
I have used the following way to achieve that.
//Get the handles
window = UIATarget.localTarget().frontMostApp().mainWindow();
target = UIATarget.localTarget();
app = target.frontMostApp();
//Get the handle for the alert
var alertHandle = app.alert();
//Do a log Element tree for the alert to get the coordinates, height and width of the alert
alertHandle.logElementTree();
//Decide the coordinates of the point based on the value of the alert coordinates
target.tap({x:50,y:150});
这篇关于如何使用2个按钮处理一个iPhone警报(需要单击非默认按钮)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!