UIAutomation 中的 UIAlert 处理
我正在尝试测试应用程序中 UIAlertview 的存在。
从 文档 我添加了脚本开头的以下处理程序。
UIATarget.onAlert = function onAlert(alert) {
var title = alert.name();
// add a warning to the log for each alert encountered
UIALogger.logWarning("Alert with title '" + title + "' encountered!");
UIATarget.localTarget().captureScreenWithName("alert_" + (new Date()).UTC());
// test if your script should handle the alert, and if so, return true
// otherwise, return false to use the default handler
return false;
}
但是当警报弹出时,这个处理程序并没有被调用。有人可以帮我解决这个问题吗?
I am trying to test the presence of UIAlertview in app.
From the documentation i have added the following handler in the starting of the script.
UIATarget.onAlert = function onAlert(alert) {
var title = alert.name();
// add a warning to the log for each alert encountered
UIALogger.logWarning("Alert with title '" + title + "' encountered!");
UIATarget.localTarget().captureScreenWithName("alert_" + (new Date()).UTC());
// test if your script should handle the alert, and if so, return true
// otherwise, return false to use the default handler
return false;
}
But this handler is not being called when the alert pop ups. Can any one help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果警报很快弹出,则可能会发生这种情况。 来访问其标题。
您仍然可以通过注意:在 iOS7 之前省略
scrollViews()[0]
It might happen if the alert pops up very soon. You can still access its title with
Note: leave out
scrollViews()[0]
prior to iOS7.