After scratching my head for many hours, I have finally figured out how to hide the keyboard. So I thought I would share info.
Background
There are two documented methods to hide the keyboard:
driver.hideKeyboard()
driver.hideKeyboard(String)
Both these methods (as of date) have open bugs on Appium's Github page. In general, they do not appear to work reliably for iOS.
So how to hide the keyboard? (a workaround)
- First, manually create the situation where your keyboard will be raised. (For example, enter text in a
UIATextField
.)
- Now observe the raised keyboard on your iPhone. What is the bottom-right key saying?
- In my example screenshot, the key is called
return
.
- Next, verify that manually pressing this key hides the keyboard.
If yes, you can go ahead and use:
driver.sendKeys(Keys.RETURN)
Notes
- Verified on Appium 1.4.13, OSX 10.11, iOS 9.1, Appium Java Client 3.3.0.