我想通过 appium 执行模拟器命令以进行自动化 Android 测试。
adb shell 命令可以像这样轻松执行 ->
driver.executeScript("mobile: shell", ImmutableMap.of("command", "dumpsys window windows | grep -E 'mCurrentFocus'"))
有什么方法可以执行以下命令“adb emu network delay gprs”
最佳答案
正确的语法是:
Map<String, Object> argv = new HashMap<>();
argv.put("command", "dumpsys ");
argv.put("args", Lists.newArrayList("window", "windows", "|", "grep", "-E", "'mCurrentFocus'"));
String result = driver.executeScript("mobile: shell", argv).toString();
引用:How To Execute Shell Commands On The Remote Device
对了,还有Appium SeeTest Extensions它为运行命令提供了简化的语法,例如:
driver.executeScript("seetest:client.run(\"adb shell dumpsys window windows | grep -E 'mCurrentFocus'\")");
关于android - 如何通过appium执行模拟器命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57073548/