gpt4 book ai didi

javascript - 什么都没做时点击了取消按钮

转载 作者:行者123 更新时间:2023-11-29 01:35:39 25 4
gpt4 key购买 nike

我确实阅读了那三个帖子:

  1. Handling Alert with UIAutomation

  2. UIAutomation : Cancel button on Alert view is tapped without actually doing it

  3. UIATarget.onAlert = function onAlert(alert) Issue - Script doesn't seem to go into block correctly

我知道这个问题可以解决。我尝试使用人们在帖子中提出的方法,但它对我来说并不真正有效。我想在这里再问一下...

所以我需要在警报窗口中输入密码。像这样:

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.
}

第二件事是,您似乎正在 try catch 由您自己的应用程序生成的警报:

target.frontMostApp().keyboard().typeString("1234");

您不使用 onAlert 来捕获这些; onAlert 用于处理权限弹出窗口等 iOS 警报。

关于javascript - 什么都没做时点击了取消按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33003947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com