Hide keyboard iOS make crash the app

Hi guys,

I’m currently using Appium to test a login view on my iOS app.
Basically, my login button is under the keyboard when it shows for a field. So I want to hide keyboard before clicking on it.

I tried driver.hideKeyboard()'; that doesn’t work at all. I’ve got a error message from Appium server saying ‘Failed hide the keyboard’.

Okay, then I tried driver.hideKeyboard("Hide keyboard");, I’ve read that adding key can help. That’s the funny part: It’s actually work, the keyboard is hidden. BUT Appium server keep saying ’ Failed hide the keyboard’.

Here is the Appium server logs just before:

info: [debug] Pushing command to appium work queue: "au.hideKeyboard('pressKey','Hide keyboard')"
info: [debug] Sending command to instruments: au.hideKeyboard('pressKey','Hide keyboard')
info: [debug] [INST] 2015-08-05 11:19:26 +0000 Debug: Got new command 32 from instruments: au.hideKeyboard('pressKey','Hide keyboard')
info: [debug] [INST] 2015-08-05 11:19:26 +0000 Debug: evaluating au.hideKeyboard('pressKey','Hide keyboard')
info: [debug] [INST] 2015-08-05 11:19:26 +0000 Debug: Hiding keyboard with keyName Hide keyboard
info: [debug] [INST] 2015-08-05 11:19:26 +0000 Debug: target.frontMostApp().keyboard().buttons()["Hide keyboard"].tap()

info: [debug] Socket data received (50 bytes)

info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":17,"value":"Failed to hide keyboard."}
info: [debug] Responding to client with error: {"status":17,"value":{"message":"An error occurred while executing user supplied JavaScript.","origValue":"Failed to hide keyboard."},"sessionId":"e8ea0130-3b17-405a-b329-70b61861d461"}
info: <-- POST /wd/hub/session/e8ea0130-3b17-405a-b329-70b61861d461/appium/device/hide_keyboard 500 17892.863 ms - 185 
info: --> DELETE /wd/hub/session/e8ea0130-3b17-405a-b329-70b61861d461 {}
info: Shutting down appium session
info: [debug] Stopping ios

So I’m a bit confused: the UI hides well the keyboard, but Appium sends back an error, that’s obviously crash the test.

I’m currently using Appium 1.4.8.


1 Like

I know this is an old topic. Replying for my own records:
From the java docs for Appium see

These provide various methods: driver.hideKeyboard() and driver.hideKeyboard(String).
In the 2nd method, you provide a String that corresponds to the button on the keyboard that you need to press, in order for the hide-keyboard action to work.

1 Like