Search code examples
androidadbappium

Appium does not start the test on Expo App on Android


My goal is to run end-to-end tests with Appium on an App built with Expo (turtle-cli).

I try to start a test session with Appium-Desktop with this parameters:

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

The app launches on the smartphone, but I get a timeout error from 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

The interesting part is the adb shell command. When I run this command manually, the app launches, but the command does not finish - it just hangs forever.

$ 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 }

When I remove the parameter -W it is not blocking.

Do you have advice on how to start Appium tests on an Expo app OR do you have any idea how I can change Appium to don't use the -W flag?

Here is the apk, if you want to test it: expo-app-test apk file


Solution

  • From appium 1.14.0 there is the option to skip the waiting:

    appWaitForLaunch: false
    

    This will allow avoiding -W option on the adb command. For now you have to install the appium beta version, because it is not released, yet.

    npm install -g appium@beta