android - 如何通过appium执行模拟器命令

标签 android testing cmd automated-tests appium

我想通过 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/

相关文章:

testing - 在 TechTalk SpecFlow 中,如何放弃场景?

regex - Windows cmd脚本从jar文件中提取版本号

windows - 使用 Windows 命令 shell 创建多个文件

java - Android 应用程序启动时不显示 GIF

android - 从服务 : alternate flow of events 使用 Google Play 服务

Android:如何通知其他 Activity 完成的 Activity ()

android - 在android中创建子菜单

html - 如何在 Protractor e2e 测试中从列表(表)中获取行?

mysql - 使用命令行在Mysql中导入压缩文件

api - 测试 OpenGL API