Soft keyboard not present, cannot hide keyboard - Appium android

前端 未结 2 353
长情又很酷
长情又很酷 2021-01-12 03:42

I am getting following exception:

 org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (Original          


        
相关标签:
2条回答
  • 2021-01-12 04:22

    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.

    0 讨论(0)
  • 2021-01-12 04:39

    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

    0 讨论(0)
提交回复
热议问题