Reputation: 1
I want to hide the keyboard after entering data in the fields. For the situation when there is return button in device keyboard the below code works fine.
IOSDriver< WebElement> AD= (IOSDriver) driver;
AD.getKeyboard().sendKeys(Keys.RETURN);
But when there is a done button it doesn't. I suppose we have to add this button.
Upvotes: 0
Views: 1818
Reputation: 79
Try this it should work after entering click on Done
((IOSDriver)driver).findElement(By.xpath("//XCUIElementTypeButton[@name='Done']")).click();
Upvotes: 0
Reputation: 880
From java-client's IOSDriver class: http://appium.github.io/java-client/
public void hideKeyboard(String strategy, String keyName)
Description copied from interface: IOSDeviceActionShortcuts
Hides the keyboard if it is showing. Available strategies are PRESS_KEY and TAP_OUTSIDE. One taps outside the keyboard, the other presses a key of your choosing (probably the 'Done' key). Hiding the keyboard often depends on the way an app is implemented, no single strategy always works.
So you'll need to use the following command to press Done on the keyboard:
AD.hideKeyboard("PRESS_KEY", "Done");
Upvotes: 1