软键盘不存在,无法隐藏键盘 - Appium android
Soft keyboard not present, cannot hide keyboard - Appium android
我遇到以下异常:
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
if mInputShown=true
then yes 软件键盘已经弹出。然后使用 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()
,因为它在所有设备上的行为可能不尽相同。
我也遇到这个错误,我在 setUp 方法中使用以下代码更正了它:
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
您可以在此处查看答案:
我遇到以下异常:
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
if mInputShown=true
then yes 软件键盘已经弹出。然后使用 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()
,因为它在所有设备上的行为可能不尽相同。
我也遇到这个错误,我在 setUp 方法中使用以下代码更正了它:
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
您可以在此处查看答案: