Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appium hidekeyboard() method

Tags:

I'm trying to automate a zipcode input field which popup a num keyboard for user input. Appium could input the zipcode properly, but facing a problem when folding the keyboard, I notice there's appium menthod driver.hidekeyboard()

But unfortunately it's gives error when I using it.

Webdriver error:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: [object Object]

Appium Server log:

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/[email protected]@appium-base-driver/lib/protocol/errors.js:789:10)
[debug] [W3C (bac0efb8)]     at ProxyRequestError.getActualError (/usr/local/lib/node_modules/appium/node_modules/[email protected]@appium-base-driver/lib/protocol/errors.js:683:14)
[debug] [W3C (bac0efb8)]     at JWProxy.command (/usr/local/lib/node_modules/appium/node_modules/[email protected]@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

I also noticed there's a override method for keyboard with parameters as: https://github.com/appium/java-client/blob/1991a8a0f9e4a3ff467dbb713cb5c51c8edc060f/src/main/java/io/appium/java_client/HidesKeyboardWithKeyName.java

driver.hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done");

But regardless that I've imported the necessary class, it still says 'The method hideKeyboard() in the type HidesKeyboard is not applicable for the arguments (String, String)'

Anyone could help on any of the above 2 issues?

Many Thanks!

like image 826
Johnnie Walker Avatar asked Mar 05 '19 03:03

Johnnie Walker


1 Answers

The Appium method hideKeyboard() is known to be unstable when used on iPhone devices, as listed in Appium’s currently known open issues. Using this method for an iOS device may cause the Appium script to hang. Appium identifies that the problem is because - "There is no automation hook for hiding the keyboard,...rather than using this method, to think about how a user would hide the keyboard in your app, and tell Appium to do that instead (swipe, tap on a certain coordinate, etc…)"

Workaround: Following the advice of the Appium documentation - use Appium to automate the action that a user would use to hide the keyboard. For example, use the swipe method to hide the keyboard if the application defines this action, or if the application defines a "hide-KB" button, automate clicking on this button.

The other workaround is to use sendkey() without clicking on the text input field.

like image 57
Suban Dhyako Avatar answered Oct 10 '22 23:10

Suban Dhyako