什么都没做时点击了取消按钮
Cancel button was tapped when nothing is done
我确实看过那三个帖子:
Handling Alert with UIAutomation
UIAutomation : Cancel button on Alert view is tapped without actually doing it
UIATarget.onAlert = function onAlert(alert) Issue - Script doesn't seem to go into block correctly
我知道这个问题可以解决。我尝试使用人们在帖子中提出的方法,但它对我来说并不适用。又想在这里问一下...
所以我需要在警报中输入密码 window。像这样:
target.frontMostApp().keyboard().typeString("1234");
我在想是不是应该先写onAlert函数,把这行代码放在onAlert函数之后?还是先写onAlert函数,再把这行代码放到onAlert函数里面?
我试过这样做:
UIATarget.onAlert = function onAlert(alert)
{
return true;
target.frontMostApp().keyboard().typeString("1234");
}
但它不起作用...取消按钮仍在被点击...谢谢!
我看到两个问题。首先,typeString
行永远不会被执行,因为它在函数中位于 return
行之后。
function myExampleFunc() {
{
doSomething(); // executes
return true; // exits from the function
doAnything(); // never executed. ever.
}
第二件事是您似乎正在尝试捕获由您自己的应用程序生成的警报:
target.frontMostApp().keyboard().typeString("1234");
你不用onAlert
来捕捉这些; onAlert
用于处理 iOS 权限弹出窗口等警报。
我确实看过那三个帖子:
Handling Alert with UIAutomation
UIAutomation : Cancel button on Alert view is tapped without actually doing it
UIATarget.onAlert = function onAlert(alert) Issue - Script doesn't seem to go into block correctly
我知道这个问题可以解决。我尝试使用人们在帖子中提出的方法,但它对我来说并不适用。又想在这里问一下...
所以我需要在警报中输入密码 window。像这样:
target.frontMostApp().keyboard().typeString("1234");
我在想是不是应该先写onAlert函数,把这行代码放在onAlert函数之后?还是先写onAlert函数,再把这行代码放到onAlert函数里面?
我试过这样做:
UIATarget.onAlert = function onAlert(alert)
{
return true;
target.frontMostApp().keyboard().typeString("1234");
}
但它不起作用...取消按钮仍在被点击...谢谢!
我看到两个问题。首先,typeString
行永远不会被执行,因为它在函数中位于 return
行之后。
function myExampleFunc() {
{
doSomething(); // executes
return true; // exits from the function
doAnything(); // never executed. ever.
}
第二件事是您似乎正在尝试捕获由您自己的应用程序生成的警报:
target.frontMostApp().keyboard().typeString("1234");
你不用onAlert
来捕捉这些; onAlert
用于处理 iOS 权限弹出窗口等警报。