Appium 未在 Android 开始对 Expo App 进行测试

Appium does not start the test on Expo App on Android

我的目标是 运行 在使用 Expo (turtle-cli) 构建的应用程序上使用 Appium 进行端到端测试。

我尝试使用以下参数启动 Appium-Desktop 测试会话:

{
  "platformName": "android",
  "deviceName": "ENU7N15B0300...",
  "app": "path-to-apk",
  "automationName": "UiAutomator2"
}

应用程序在智能手机上启动,但我从 Appium 收到超时错误:

[MJSONWP] Encountered internal error running command: Error: Cannot start the 'com.example.testetoeapplauda' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command 'adb -P 5037 -s ENU7N15B03007818 shell am start -W -n com.example.testetoeapplauda/host.exp.exponent.MainActivity -S' timed out after 20000ms'. Try to increase the 20000ms adb execution timeout represented by 'adbExecTimeout' capability

有趣的部分是 adb shell 命令。当我手动 运行 这个命令时,应用程序启动,但命令没有完成 - 它永远挂起。

$ adb -P 5037 -s ENU7N15B03007818 shell am start -W -n com.example.testetoeapplauda/host.exp.exponent.MainActivity -S
Stopping: com.example.testetoeapplauda
Starting: Intent { cmp=com.example.testetoeapplauda/host.exp.exponent.MainActivity }

当我删除参数 -W 时,它不会阻塞。

您对如何在 Expo 应用程序上启动 Appium 测试有什么建议吗或者您是否知道我可以如何将 Appium 更改为不使用 -W旗帜?

这是apk,如果你想测试它:expo-app-test apk file

从 appium 1.14.0 开始,可以选择跳过等待:

appWaitForLaunch: false

这将允许在 adb 命令中避免使用 -W 选项。 现在你必须安装 appium beta 版本,因为它还没有发布。

npm install -g appium@beta