首页 > 解决方案 > 在同时运行的多个模拟器上运行相同的 ADB Shell 脚本

问题描述

在使用多个工作人员运行自动化 UI 测试时,我想执行以下脚本:

    beforeAll(async () => {
    if (device.getPlatform() === 'android') {
      console.log('*** disable android system popups ***')
      execSync(
        'adb shell settings put secure immersive_mode_confirmations confirmed'
      )
    }
    await device.launchApp()
  })

这将不起作用,因为 shell 不知道要定位哪个模拟器。

Command failed: adb shell settings put secure immersive_mode_confirmations confirmed
adb: more than one device/emulator

有没有办法使用相同的命令一次简单地定位所有模拟器实例?或者我可以以某种方式adb devices使用 JS 访问列表并将命令映射到每个实例吗?

标签: androidautomated-testsadbandroid-popupwindowandroid-immersive

解决方案


推荐阅读