Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide keyboard in iOS mobile automation using Appium

Tags:

ios

appium

I am using iOS version of 10.2 and xcode version is 8.3.

Can anyone let me know how to hide the keyboard in iOS mobile automation using Appium?

programming language used: Java.

like image 513
Arijit Biswas Avatar asked Oct 13 '25 12:10

Arijit Biswas


2 Answers

I tried driver.hideKeyboard(), but it doesn't work for me.

So, I tried with way:

  1. by pressing the button specified key name and way
  2. inspect key coordinate with appium and perform action. Both ways are work for me.
// way 1
driver.findElementByXPath(String.format("//XCUIElementTypeButton[@name='%s']", "Done")).click();

// way 2
TouchAction touchAction = new TouchAction(driver);
touchAction.tap(new PointOption().withCoordinates(345, 343)).perform();
like image 86
Byaku Avatar answered Oct 15 '25 08:10

Byaku


You could use java_client library methods:

driver.findElementByAccessibilityId("Hide keyboard").click();

driver.hideKeyboard(HideKeyboardStrategy.TAP_OUTSIDE);

driver.hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done");
like image 44
MrBlack Avatar answered Oct 15 '25 09:10

MrBlack