【发布时间】:2013-07-15 09:36:48
【问题描述】:
我正在尝试从应用程序中注销。当我点击“注销”时,它会给我一个警告框 -> 有两个按钮“是”和“取消”,但我无法点击“是”按钮.我尝试了以下代码:
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 打印任何消息,因此也无法使用坐标方法。
【问题讨论】:
-
听起来您的警报处理程序根本没有被调用,基于您从未在跟踪日志中看到该日志消息的证据。你什么时候尝试测试这个?它在整个测试脚本的最后吗?如果是这样,您需要在其中放置某种手册
target.delay(5),因为自动化脚本引擎将在屏幕上完全形成警报之前结束,并且永远不会调用您的警报回调。在脚本完成前暂停片刻将使脚本引擎有时间注意到警报并给您回电。
标签: javascript iphone ipad ios-ui-automation