我得到以下异常: 
  
  
 
org.openqa.selenium.WebDriverException: An unkNown server-side error occurred while processing the command. (Original error: Soft keyboard not present,cannot hide keyboard) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 368 milliseconds 
 我正在使用driver.hideKeyboard()来隐藏屏幕上打开的软输入键盘.如何在隐藏键盘之前确保键盘处于打开状态?或任何其他解决方法?
解决方法
 使用adb命令检查键盘是否弹出 
  
  
 
        adb shell dumpsys input_method | grep mInputShown Output : mShowRequested=true mShowExplicitlyRequested=false mShowForced=false mInputShown=true
如果mInputShown = true则弹出软键盘.然后使用driver.pressKeyCode(AndroidKeyCode.BACK);
使用java的一种方法是
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:请不要使用driver.navigate().back(),因为它的行为在所有设备上可能不一样.