appium / appium-uiautomator2-driver

Appium driver for Android UIAutomator2
Apache License 2.0
607 stars 178 forks source link

Installation is frequently failing #839

Closed tking16 closed 3 days ago

tking16 commented 4 days ago

In a suite of 70 or so tests, recently several of them will error before they even run as it seems to app fails to install.

E       selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command '/Users/jenkins/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.63.160.55\:5555 install -r -t /Users/jenkins/test_apps/android_apks/7278/merge/artifact/app-global-debug.apk' timed out after 60000ms'. Try to increase the 60000ms adb execution timeout represented by 'androidInstallTimeout' capability
E       Stacktrace:
E       UnknownError: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command '/Users/jenkins/Library/Android/sdk/platform-tools/adb -P 5037 -s 10.63.160.55\:5555 install -r -t /Users/jenkins/test_apps/android_apks/7278/merge/artifact/app-global-debug.apk' timed out after 60000ms'. Try to increase the 60000ms adb execution timeout represented by 'androidInstallTimeout' capability
E           at getResponseForW3CError (/Users/jenkins/actions-runner/_at-tests/guacamole/guacamole/testing/app-at/node_modules/@appium/base-driver/lib/protocol/errors.js:1145:9)
E           at asyncHandler (/Users/jenkins/actions-runner/_at-tests/guacamole/guacamole/testing/app-at/node_modules/@appium/base-driver/lib/protocol/protocol.js:485:57)

As it suggests I tried increasing the timeout, didn't do anything.

For added context it's failing specifically at the restart_app function in my conftest file. which is run before each test, I have no idea why this sometimes works and sometimes doesn't. The functions is as follows:

def restart_app(appium_extended, platform, bundle_id):
    if platform == 'ios':
        appium_extended.terminate_app(bundle_id)
        appium_extended.remove_app(bundle_id)
        appium_extended.install_app(appium_extended.capabilities['app'])
    else:
        appium_extended.remove_app(bundle_id)
        appium_extended.install_app(appium_extended.capabilities['app'], allowTestPackages="true")
        appium_extended.execute_script('mobile:clearApp', {"appId": bundle_id}) # somehow installing with existing data
        appium_extended.execute_script('mobile:changePermissions', {"permissions": "android.permission.ACCESS_COARSE_LOCATION",
                                                                    "action": "grant"})
    appium_extended.activate_app(bundle_id)

appium.log

mykola-mokhnach commented 4 days ago

I would not do the full reinstall because Android OS limits the number of reinstalls for a single app. clearApp and restart should be enough.

tking16 commented 3 days ago

@mykola-mokhnach Thanks, it's early days but they seem to be a bit more stable now with that change