Appium iOS Real Device Hide Keyboard

Appium 1.5.3
Xcode 7.3.1
Java-client 3.3.0
iPad Air 2

How do you guys hide keyboard?
When I input username and password with send keys method my login button is not visible anymore.

I can locate username/password by xpath (given to me through inspector). I can send info to those elements with sendKeys method.
However, when I try to locate keyboard button “hide keyboard” with xpath my script crashes.

Can someone point me to the right direction?
What I am trying to do: enter username/password, then hide keyboard as it blocks login button, and then click login button.

Thank you.

These threads might help:

I tried the first link before I made my own post. Unfortunately, those suggestions did not work for me.

Ok, solved a problem by using this from the link posted above (Appium iOS Guide: hiding the keyboard on real devices):

is not working for me.

The below worked for me.

MobileElement keyboard = iosdriver.findElement(MobileBy.className(“UIAKeyboard”));

I tried all the solutions, but none of them worked.

What error did you get with

MobileElement keyboard = iosdriver.findElement(MobileBy.className(“UIAKeyboard”));



public static WebDriver driver;
driver = new RemoteWebDriver(new URL(URL), caps);

((HidesKeyboardWithKeyName) driver).hideKeyboard(HideKeyboardStrategy.TAP_OUTSIDE);
((HidesKeyboardWithKeyName) driver).hideKeyboard(HideKeyboardStrategy.PRESS_KEY, “Go”);

Error: org.openqa.selenium.remote.RemoteWebDriver cannot be cast to io.appium.java_client.HidesKeyboardWithKeyName

I also tried to cast like: iosDriver=(IOSDriver<?>) driver;

MobileElement keyboard = driver.findElement(MobileBy.className(“UIAKeyboard”));


What is the error when you use the above?

1 Like

It was required to have casting and done.
Thanks for the time and solution. How do you know it’s UIAKeyBoard as class and Is there any reference info from where I can get info?

Although I always get below exception

org.openqa.selenium.remote.RemoteWebElement cannot be cast to io.appium.java_client.MobileElement

You can’t hide keyboard on iOS, you need to implement a gesture just like a normal user would to. E.g. tap somewhere on empty area.

1 Like