【问题标题】:Unable to enter texts in passcode textfields for iOS UI testing无法在密码文本字段中输入文本以进行 iOS UI 测试
【发布时间】:2015-08-19 18:19:03
【问题描述】:

这是我在 Xcode 上运行 UI 测试的代码:

     var target = UIATarget.localTarget();
     var app = target.frontMostApp();

     var window = app.mainWindow();

     //display the current screen 
     target.logElementTree();

     //set value as email address
     window.textFields()[0].setValue("test11@test.com");
     //set value in passcode 
     window.textFields()[1].setValue("1234");


     window.buttons()["SIGN IN"].tap();

应用界面如下所示:

对于线路:

    Window.textFields()[0].setValue("1234");

它显示:

    Unexpected error in -[UIATextField_0x7fc8ac0e360 setValue:],/SourceCache/UIAutomation_Sim/UIAutomation-430.2.1/Frameworks/UIElement.m.line 1088, kAXErrorCannotComplete

所以当脚本输入电子邮件地址而不是密码时它可以工作。我认为该应用程序检测到密码是由机器人而不是人类输入的。这就是为什么它会产生错误?如果是这样,我该如何解决?

【问题讨论】:

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


    【解决方案1】:

    这是一个安全问题。

    为了测试原因,取消选中圆圈框,然后问题修复!

    【讨论】:

      【解决方案2】:

      您可以在 Interface Builder 中选中“安全文本字段”框,并使用 window.secureTextFields 而不是 window.textFields 引用它

      【讨论】:

        猜你喜欢
        • 2015-01-27
        • 2019-03-14
        • 2016-08-15
        • 1970-01-01
        • 2015-12-25
        • 1970-01-01
        • 2016-01-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多