没有任何操作时点击取消按钮

时间:2015-10-07 23:10:21

标签: javascript ios xcode alert ios-ui-automation

我确实阅读了这三篇文章:

  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

  4. 我知道这个问题可以修复。我尝试使用人们在帖子中提出的方法,但它并不适合我。我想再问一遍......

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

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

    我想知道我是否应该首先编写onAlert函数,并将这行代码放在onAlert函数之后?或者首先编写onAlert函数,然后将这行代码放在onAlert函数中?

    我试着这样做:

     UIATarget.onAlert = function onAlert(alert)
    
     {
    
       return true;
    
       target.frontMostApp().keyboard().typeString("1234");
    
    }
    

    但它不起作用......取消按钮仍然被点击......谢谢!

1 个答案:

答案 0 :(得分:1)

我看到两个问题。首先,return行永远不会被执行,因为它出现在函数中的function myExampleFunc() { { doSomething(); // executes return true; // exits from the function doAnything(); // never executed. ever. } 行之后。

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

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

onAlert

你不能使用onAlert来抓住这些; Dim c As Integer Private Sub Command4_Click() c = InputBox("ENTER STAFF ID") Form6.Adodc1.Refresh Form6.Adodc1.Recordset.MoveFirst `ERROR While Form6.Adodc1.Recordset.EOF <> True If Form6.Adodc1.Recordset.Fields(0) = Val(c) Then Text1.Text = Form6.Adodc1.Recordset.Fields(0) Text1.Enabled = False Text2.Text = Form6.Adodc1.Recordset.Fields(1) Text3.Text = Form6.Adodc1.Recordset.Fields(2) Text4.Text = Form6.Adodc1.Recordset.Fields(5) DTPicker2.Enabled = False DTPicker1.Enabled = False MsgBox "AFTER EDITING CLICK ON UPDATE" Command2.Enabled = True Exit Sub Else Form6.Adodc1.Recordset.MoveNext End If Wend MsgBox "ENTER CORRECT STAFF ID" End Sub 用于处理权限弹出窗口等iOS警报。