How to remove keyboard in appium using Java?

This code is only for finding a text field and sending it some text. When he does this, the keyboard appears on the Android device. How to reject it after sendKeys.

@Test public static void test_demo() throws Exception { WebElement element = driver.findElement(By.id("mytextfield")); element.sendKeys("test"); //how do I dismiss keyboard which appears on my android device after sendKeys? } 
+10
source share
8 answers

driver.hideKeyboard() will only work with AppiumDriver . I am using java-client-2.2.0.jar which contains this feature.

+17
source

The best way is to use the back button.

 driver.navigate().back(); // For older version of appium 
+8
source

Add these values ​​to your desired features if you want to disable the keyboard on your selenium tests.

 capabilities.setCapability("unicodeKeyboard", true); capabilities.setCapability("resetKeyboard", true); 
+4
source

Please use Appium 1.0

Add libraries or add maven dependency on Appium Java client:

 <dependency> <groupId>io.appium</groupId> <artifactId>java-client</artifactId> <version>1.1.0</version> </dependency> 

Create the driver instance as follows:

 AppiumDriver driver=null; driver= new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities); 

And to hide the keyboard, use the following function:

 driver.hideKeyboard(); 
+2
source

I am using driver.hideKeyboard(); every time I use sendKeys() to input something. Works great for me.

+2
source
 public static AndroidDriver driver= null; ...... driver.hideKeyboard(); 

will work fine based on my experience

+1
source
 capabilities.setCapability("unicodeKeyboard", true); capabilities.setCapability("resetKeyboard", true); 

Still working with 1.7.2 and assuming 1.8

+1
source

Solution for those who do not use AppiumDriver :

 ((AppiumDriver)driver).hideKeyboard(); 
0
source

All Articles