Javascript 我可以在警报功能中使用滚动和单击操作脚本吗?

Javascript 我可以在警报功能中使用滚动和单击操作脚本吗?,javascript,iphone,ios,ios-ui-automation,Javascript,Iphone,Ios,Ios Ui Automation,我有如下警报功能: UIATarget.onAlert = function onAlert(alert) { var title = alert.name(); UIALogger.logWarning("Alert with title '" + title + "' encountered!"); if (title == "Installation for this product is actually free with delivery - you will not be ch

我有如下警报功能:

UIATarget.onAlert = function onAlert(alert) 
{
var title = alert.name();
UIALogger.logWarning("Alert with title '" + title + "' encountered!");

if (title == "Installation for this product is actually free with delivery - you will not be charged for installation.") 
{ 
alert.buttons()["OK"].tap();

return true; // bypass default handler 
}
return false; // use default handler 
}
这里我想执行一个条件,如果出现警报消息,我想执行

mainWindowTarget.scrollViews()[0].scrollToElementWithName("Add to cart");

var AddButton = mainWindowTarget.scrollViews()[0].buttons().firstWithName("Add to cart").tap();
因此,一旦警报消息出现,应执行上述两行


有人能帮上忙吗

警报功能将处理弹出的警报并自动调用。但是,要使用滚动视图并点击它,您首先必须关闭警报弹出窗口,然后返回具有滚动视图的屏幕。但是做同样的实验是很好的