这是我在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
当脚本输入电子邮件地址但不输入密码时,它会起作用。我认为应用程序检测到密码是由机器人输入的,而不是人类输入的。这就是它产生错误的原因?如果是这样,我该如何解决?