获取文本字段Appium for iOS



我正在appium测试用例中尝试访问我的应用程序登录页面的文本字段。目前,我正在使用"Restoration Id"来识别文本字段,并将其用作唯一标识符。

目前appium无法通过"Restoration Id"找到文本字段,并给出错误

info: [debug] Socket data received (25 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":""}
info: [debug] Id selector, 'com.myapps.myappDummyName:id/loginButton', not found in Localizable.strings.
info: [debug] Pushing command to appium work queue: "au.getElementById('com.myapps.myappDummyName:id\/loginButton')"
info: [debug] Sending command to instruments: au.getElementById('com.myapps.myappDummyName:id/loginButton')
info: [debug] [INST] 2016-05-17 12:54:11 +0000 Debug: Got new command 68 from instruments: au.getElementById('com.myapps.myappDummyName:id/loginButton')
info: [debug] [INST] 2016-05-17 12:54:11 +0000 Debug: evaluating au.getElementById('com.myapps.myappDummyName:id/loginButton')
info: [debug] [INST] 2016-05-17 12:54:11 +0000 Debug: evaluation finished
info: [debug] [INST] 2016-05-17 12:54:11 +0000 Debug: responding with:
info: [debug] [INST] 2016-05-17 12:54:11 +0000 Debug: Running system command #69: /usr/local/Cellar/node/5.6.0/bin/node /Users/Harry/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":""}...
info: [debug] Socket data received (25 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":""}
info: [debug] Condition unmet after 6942ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":""},"sessionId":"345b24b8-82da-31da-85c1-45ae33325c15"}

有人能告诉我如何使用findElementById()方法并向其传递唯一id来获取文本字段吗?我如何从故事板中的UITextField获取该id,以及在故事板中指定该id的位置。

WebElement textField = driver.findElement(By.id("<resource-id of element>"));

如果您正确地指定了id,这行代码将允许您在文本字段中有一个元素。

我可以从日志中读取的内容:

info:[debug]Id选择器,'com.myapps.myappDummyName:Id/loginButton',在Localizable.strings.中找不到

您可能使用了不正确的id字符串来访问元素。

另外,我希望你没有面临这样的问题:IOS故事板:恢复ID就像故事板ID一样?

相关内容

  • 没有找到相关文章

最新更新