Appium iOS Real Device Hide Keyboard


#1

Environment:
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.


#2

These threads might help:



#3

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


#4

Ok, solved a problem by using this from the link posted above (Appium iOS Guide: hiding the keyboard on real devices):
driver.getKeyboard().pressKey("\n");


#5

driver.getKeyboard().pressKey("\n");
is not working for me.


#6

The below worked for me.

MobileElement keyboard = iosdriver.findElement(MobileBy.className(“UIAKeyboard”));
keyboard.findElements(By.name(“Done”)).get(0).click();


#7

I tried all the solutions, but none of them worked.
java-client-6.1.0


#8

What error did you get with

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

keyboard.findElements(By.name(“Done”)).get(0).click();

#9

Hey,

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;


#10

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

keyboard.findElements(By.name(“Done”)).get(0).click();

What is the error when you use the above?


#11

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?


#12

Although I always get below exception

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


#13

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.