在代碼中執行adb命令
String cmd="adb shell input keyevent 4";
try {
Runtime.getRuntime().exec(cmd).waitFor();
Thread.sleep(10000);
} catch (Exception e) {
e.printStackTrace();
}
結果一執行appium直接停止session,查文檔發現如果要執行cmd,需要執行appium destop時勾選下面選項
或者
appium --relaxed-security -U udid