我正在尝试自动化一个zipcode输入字段,该字段弹出一个num键盘,用于用户输入。Appium可以正确地输入the代码,但是当折叠键盘时,我注意到有appium driver.hidekeyboard()
但不幸的是,当我使用它时,它会产生错误。
网络驱动程序错误:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: [object Object]Appium Server日志:
debug] [JSONWP Proxy] Matched '/element/undefined/click' to command name 'click'
[debug] [JSONWP Proxy] Proxying [POST /element/undefined/click] to [POST http://localhost:8100/session/83293E4F-4B7A-462A-B5B1-1D729D54E36B/element/undefined/click] with body: {}
[debug] [XCUITest] Connection to WDA timed out
[debug] [iProxy] recv failed: Operation not permitted
[debug] [JSONWP Proxy] Got response with status 200: {"value":{},"sessionId":"83293E4F-4B7A-462A-B5B1-1D729D54E36B","status":13}
[JSONWP Proxy] Got an unexpected response: {"value":{},"sessionId":"83293E4F-4B7A-462A-B5B1-1D729D54E36B","status":13}
[debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError
[debug] [XCUITest] Connection to WDA timed out
[debug] [iProxy] recv failed: Operation not permitted
[debug] [W3C (bac0efb8)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: [object Object]
[debug] [W3C (bac0efb8)] at errorFromMJSONWPStatusCode (/usr/local/lib/node_modules/appium/node_modules/_appium-base-driver@3.14.0@appium-base-driver/lib/protocol/errors.js:789:10)
[debug] [W3C (bac0efb8)] at ProxyRequestError.getActualError (/usr/local/lib/node_modules/appium/node_modules/_appium-base-driver@3.14.0@appium-base-driver/lib/protocol/errors.js:683:14)
[debug] [W3C (bac0efb8)] at JWProxy.command (/usr/local/lib/node_modules/appium/node_modules/_appium-base-driver@3.14.0@appium-base-driver/lib/jsonwp-proxy/proxy.js:234:19)
[HTTP] <-- POST /wd/hub/session/bac0efb8-601a-4558-a50c-f909f2ccb25a/appium/device/hide_keyboard 500 1我还注意到有一个用于键盘的覆盖方法,参数为:client/HidesKeyboardWithKeyName.java
driver.hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done");但是,不管我导入了必要的类,它仍然说‘hideKeyboard()类型中的方法HidesKeyboard不适用于参数(String,String)’
有人能在上面的两个问题上提供帮助吗?
非常感谢!
发布于 2019-03-05 04:14:24
Appium方法hideKeyboard()是已知的,用于iPhone设备时是不稳定的,如Appium当前已知的未决问题中所列。将此方法用于iOS设备可能会导致Appium脚本挂起。Appium认为问题在于:“没有自动挂钩来隐藏键盘,...rather比使用这种方法更能考虑用户如何在应用程序中隐藏键盘,并告诉Appium这样做(滑动、点击某个坐标等…)。”
解决办法:遵循Appium文档的建议--使用Appium自动执行用户用于隐藏键盘的操作。例如,如果应用程序定义了此操作,或者如果应用程序定义了“隐藏-KB”按钮,则使用swipe方法隐藏键盘,然后自动单击此按钮。
另一个解决方法是使用sendkey()而不单击文本输入字段。
发布于 2019-03-05 04:12:46
众所周知,Appium方法hideKeyboard()在iPhone设备上使用时是不稳定的,如Appium当前已知的未决问题中所列出的。将此方法用于iOS设备可能会导致Appium脚本挂起。Appium认为问题是因为-“没有自动挂钩隐藏键盘,...rather比使用这种方法,考虑用户将如何隐藏键盘在您的应用程序,并告诉Appium这样做(滑动,点击某个坐标,等等)。
如果要隐藏键盘,可以编写如下所示的函数
public void typeAndEnter(MobileElement mobileElement, String keyword) {
LOGGER.info(String.format("Typing %s ...",keyword));
mobileElement.sendKeys(keyword, Keys.ENTER);
}希望这能有所帮助
发布于 2019-03-12 07:18:58
您也可以简单地使用
driver.navigate().back(); (适用于较旧版本的appium)
https://stackoverflow.com/questions/54995027
复制相似问题