hideKeyboard - An error occurred while executing user supplied JavaScript

Attempting to hide the keyboard using the AppiumDriver hideKeyboard method results in the following exception:
org.openqa.selenium.WebDriverException: An error occurred while executing user supplied JavaScript

Appium v2.43.1
iPhone Simulator iOS 8.1

Extract from logs:

2015-01-02 12:50:02:231 - info: --> POST /wd/hub/session/94f6d026-276f-4d1c-b3c2-52cbbecc5aa9/appium/device/hide_keyboard {}
2015-01-02 12:50:02:232 - info: [debug] Pushing command to appium work queue: “au.hideKeyboard(‘default’)”
2015-01-02 12:50:02:233 - info: [debug] Sending command to instruments: au.hideKeyboard(‘default’)
2015-01-02 12:50:02:386 - info: [debug] [INST] 2015-01-02 12:50:02 +0000 Debug: Got new command 21 from instruments: au.hideKeyboard(‘default’)
2015-01-02 12:50:02:408 - info: [debug] [INST] 2015-01-02 12:50:02 +0000 Debug: evaluating au.hideKeyboard(‘default’)
2015-01-02 12:50:02:433 - info: [debug] [INST] 2015-01-02 12:50:02 +0000 Debug: target.frontMostApp().mainWindow().tapWithOptions({})
2015-01-02 12:50:02:772 - info: [IOS_SYSLOG_ROW ] Jan 2 04:50:02 itako21075.prod.miso filecoordinationd[801]: (Error) FileProvider: Could not load bundle com.apple.CloudDocsFileProvider. Error: The bundle “CloudDocsFileProvider” couldn’t be loaded because it is damaged or missing necessary resources.
2015-01-02 12:50:16:267 - info: [IOS_SYSLOG_ROW ] Jan 2 04:50:16 itako21075.prod.miso mstreamd[729]: (Note ) PS: Media stream daemon stopping.
2015-01-02 12:50:16:311 - info: [IOS_SYSLOG_ROW ] Jan 2 04:50:16 itako21075.prod.miso mstreamd[729]: (Note ) AS: <MSIOSAlbumSharingDaemon: 0x7fa2c051c380>: Shared Streams daemon has shut down.
2015-01-02 12:50:16:312 - info: [IOS_SYSLOG_ROW ] Jan 2 04:50:16 itako21075.prod.miso mstreamd[729]: (Warn ) mstreamd: mstreamd shutting down.
2015-01-02 12:50:19:862 - info: [debug] Socket data received (50 bytes)
2015-01-02 12:50:19:863 - info: [debug] Socket data being routed.
2015-01-02 12:50:19:863 - info: [debug] Got result from instruments: {“status”:17,“value”:“Failed to hide keyboard.”}
2015-01-02 12:50:19:863 - 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”:“94f6d026-276f-4d1c-b3c2-52cbbecc5aa9”}
2015-01-02 12:50:19:864 - info: <-- POST /wd/hub/session/94f6d026-276f-4d1c-b3c2-52cbbecc5aa9/appium/device/hide_keyboard 500 17632.564 ms - 185
2015-01-02 12:50:20:844 - info: [debug] [INST] 2015-01-02 12:50:19 +0000 Error: VerboseError: Failed to hide keyboard.
2015-01-02 12:50:21:001 - info: [debug] [INST] 2015-01-02 12:50:19 +0000 Error: Error during eval: hideKeyboard@file:///Users/chef/appium/C10195B5-A52D-4D9A-9EF4-D1DE9D8C587F/bootstrap-50949661197fe2cc.js:1346:52
eval code
eval@[native code]
startProcessing@file:///Users/chef/appium/C10195B5-A52D-4D9A-9EF4-D1DE9D8C587F/bootstrap-50949661197fe2cc.js:2663:30
bootstrap@file:///Users/chef/appium/C10195B5-A52D-4D9A-9EF4-D1DE9D8C587F/bootstrap-50949661197fe2cc.js:2729:31
global code@file:///Users/chef/appium/C10195B5-A52D-4D9A-9EF4-D1DE9D8C587F/bootstrap-50949661197fe2cc.js:2738:10
2015-01-02 12:50:21:019 - info: [debug] [INST] 2015-01-02 12:50:19 +0000 Debug: responding with:
2015-01-02 12:50:21:048 - info: [debug] [INST] 2015-01-02 12:50:19 +0000 Debug: Running system command #22: /usr/local/Cellar/node/0.10.22/bin/node /Users/chef/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:17,“value”:“Failed to hide keyboard.”}…

Any assistance would be greatly appreciated!

I am also facing this issue on a real iPad Mini device with XCode 6.2 and Appium 1.3.7

For me I am setting a value to an editbox and while setting it opens the keyboard and this keyboard comes over the Signin button so I am unable to click signin as it is hidden behind the keyboard. So this is a kind of blocker for me.

Here is the console error:

info: [debug] Pushing command to appium work queue: “au.hideKeyboard(‘default’)”
info: [debug] Sending command to instruments: au.hideKeyboard(‘default’)
info: [debug] [INST] 2015-04-21 12:28:11 +0000 Debug: responding with:
info: [debug] [INST] 2015-04-21 12:28:11 +0000 Debug: Running system command #41: /usr/local/Cellar/node/0.12.0/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:""}…
info: [debug] [INST] 2015-04-21 12:35:27 +0000 Debug: Got new command 41 from instruments: au.hideKeyboard(‘default’)
info: [debug] [INST] 2015-04-21 12:35:27 +0000 Debug: evaluating au.hideKeyboard(‘default’)
info: [debug] [INST] 2015-04-21 12:35:27 +0000 Debug: target.frontMostApp().mainWindow().tapWithOptions({})
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”:“5e684b54-d0de-4d07-91f3-26a4320bfbc8”}
info: <-- POST /wd/hub/session/5e684b54-d0de-4d07-91f3-26a4320bfbc8/appium/device/hide_keyboard 500 18592.068 ms - 185
info: [debug] [INST] 2015-04-21 12:35:45 +0000 Error: VerboseError: Failed to hide keyboard.
info: [debug] [INST] 2015-04-21 12:35:45 +0000 Error: Error during eval: hideKeyboard@file:///usr/local/lib/node_modules/appium/298D68FC-2943-4D6B-9184-C76C2FF22BF1/bootstrap-445563c75b389324.js:1361:52
eval code
eval@[native code]
startProcessing@file:///usr/local/lib/node_modules/appium/298D68FC-2943-4D6B-9184-C76C2FF22BF1/bootstrap-445563c75b389324.js:2693:30
bootstrap@file:///usr/local/lib/node_modules/appium/298D68FC-2943-4D6B-9184-C76C2FF22BF1/bootstrap-445563c75b389324.js:2761:31
global code@file:///usr/local/lib/node_modules/appium/298D68FC-2943-4D6B-9184-C76C2FF22BF1/bootstrap-445563c75b389324.js:2770:10
info: [debug] [INST] 2015-04-21 12:35:45 +0000 Debug: responding with:

@jvanderwee I have the same issue when I trying implement
`(IOSDriver) driver).hideKeyboard(“pressKey”, “Hide keyboard”);

I got next error
** > org.openqa.selenium.WebDriverException: An error occurred while executing user supplied JavaScript. (WARNING: The server did not provide any stacktrace information)**
** > Command duration or timeout: 1.02 seconds**
** > Build info: version: ‘2.46.0’, revision: ‘61506a4624b13675f24581e453592342b7485d71’, time: ‘2015-06-04 10:22:50’**
** > System info: host: ‘WERN18397.local’, ip: ‘172.24.1.154’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.1’, java.version: ‘1.7.0_79’**
** > Session ID: 356669d0-13bc-4f17-b7a8-6a81c266961e**
** > Driver info: io.appium.java_client.ios.IOSDriver**
** > Capabilities [{platformVersion=9.2, app=/Users/[email protected]/Library/Developer/Xcode/DerivedData/Drive_Werner-fguniiheeiakwifgeuwiupeijtzw/Build/Products/QA-iphonesimulator/Drive Werner.app, platform=MAC, databaseEnabled=false, javascriptEnabled=true, platformName=iOS, deviceName=iPhone 5s, browserName=iOS, webStorageEnabled=false, networkConnectionEnabled=false, desired={app=/Users/[email protected]/Library/Developer/Xcode/DerivedData/Drive_Werner-fguniiheeiakwifgeuwiupeijtzw/Build/Products/QA-iphonesimulator/Drive Werner.app, platformVersion=9.2, deviceName=iPhone 5s, platformName=iOS}, locationContextEnabled=false, warnings={}, takesScreenshot=true}]**
** > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)**
** > at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)**
** > at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)**
** > at java.lang.reflect.Constructor.newInstance(Constructor.java:526)**
** > at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)**
** > at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)**
** > at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)**
** > at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)**
** > at io.appium.java_client.ios.IOSDriver.hideKeyboard(IOSDriver.java:55)**
** > at com.werner.drivewernerios.cucumber.StepDefs.fillAccountCreation(StepDefs.java:250)**
** > at ✽.And I fill in the account creation fields(RegisterUserImageComparison.feature:10)**

Hi,
I have the same issue when trying to enter text into text fields. is there any workaround for this issue?

Scenario:
i. I have logged into application
ii. performed some operations and then logged out
iii. Now, in the same session, trying to login to application again and unable to enter data into text fields and got the exception
org.openqa.selenium.WebDriverException: An error occurred while executing user supplied JavaScript

Appium server 1.4.13
Appium java_client v3.2.0
iPhone Simulator iOS 8.2

Thanks in advance…