I am getting following exception:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (Original
Use adb command to check whether keyboard has popped up or not
adb shell dumpsys input_method | grep mInputShown
Output : mShowRequested=true mShowExplicitlyRequested=false mShowForced=false mInputShown=true
if mInputShown=true
then yes software keyboard has popped up. Then use driver.pressKeyCode(AndroidKeyCode.BACK);
One way to do using java is
Process p = Runtime.getRuntime().exec("adb shell dumpsys input_method | grep mInputShown");
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String outputText = "";
while ((outputText = in.readLine()) != null) {
if(!outputText.trim().equals("")){
String keyboardProperties[]=outputText.split(" ");
String keyValue[]=keyboardProperties[keyboardProperties.length-1].split("=");
String softkeyboardpresenseValue=keyValue[keyValue.length-1];
if(softkeyboardpresenseValue.equalsIgnoreCase("false")){
isKeyboardPresent=false;
}else{
isKeyboardPresent=true;
}
}
}
in.close();
PS: Please do not use driver.navigate().back()
as its behavior may not be same on all devices.
I also get this error, i correct it by using the following code in the setUp method :
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
You can check answers here : Keyboard in Android physical device isn’t always hidden while using Appium