AzimoLabs / fastlane-plugin-automated-test-emulator-run

Plugin dedicated for Android platform. Wraps gradle task/shell command used for launching instrumented tests. Provides start of as many AVDs with various configs as needed before test run, waits for boot, kills emulators and deletes them from hdd after tests are finished or disturbed.
MIT License
112 stars 48 forks source link

No permission when pulling screenshots #36

Open graf-semmel opened 4 years ago

graf-semmel commented 4 years ago

Hi there. I am using Screengrab to capture screenshots during ui tests. Screengrab runs the ui test itself and tries to pull them at the end from the device. That works fine when I run the uiTestsWithScreenshots lane separately but not when it is called from the automated_test_emulator_run plugin. I need to be adb root to be able to pull the screenshots. When I set use_adb_root: true the lane crashes

[10:17:25]: Clearing phoneScreenshots within fastlane/metadata/android
[10:17:25]: $ /Users/tristan/Library/Android/sdk/platform-tools/adb -s emulator-5556 shell echo \$EXTERNAL_STORAGE
[10:17:25]: ▸ /sdcard
[10:17:25]: $ /Users/tristan/Library/Android/sdk/platform-tools/adb root
restarting adbd as root
timeout expired while waiting for device
[10:17:31]: Exit status: 1
Traceback (most recent call last):
    30: from /usr/local/bin/fastlane:23:in `<main>'
    29: from /usr/local/bin/fastlane:23:in `load'
    28: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/bin/fastlane:23:in `<top (required)>'
    27: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/cli_tools_distributor.rb:119:in `take_off'
    26: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/commands_generator.rb:41:in `start'
    25: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/commands_generator.rb:349:in `run'
    24: from /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in `run!'
    23: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in `run!'
    22: from /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in `run_active_command'
    21: from /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in `run'
    20: from /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in `call'
    19: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run'
    18: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
    17: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/lane_manager.rb:56:in `cruise_lane'
    16: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
    15: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
    14: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
    13: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/lane.rb:33:in `call'
    12: from Fastfile:15:in `block (2 levels) in parsing_binding'
    11: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
    10: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name'
     9: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/runner.rb:227:in `execute_action'
     8: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/runner.rb:227:in `chdir'
     7: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/runner.rb:253:in `block in execute_action'
     6: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/actions/actions_helper.rb:50:in `execute_action'
     5: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/runner.rb:261:in `block (2 levels) in execute_action'
     4: from /Library/Ruby/Gems/2.6.0/gems/fastlane-plugin-automated_test_emulator_run-1.6.0/lib/fastlane/plugin/automated_test_emulator_run/actions/automated_test_emulator_run_action.rb:185:in `run'
     3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/forwardable.rb:230:in `sh'
     2: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane/lib/fastlane/helper/sh_helper.rb:80:in `sh_control_output'
     1: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane_core/lib/fastlane_core/ui/ui.rb:17:in `method_missing'
/Library/Ruby/Gems/2.6.0/gems/fastlane-2.142.0/fastlane_core/lib/fastlane_core/ui/interface.rb:153:in `shell_error!': [!] Exit status of command 'fastlane uiTestsWithScreenshots' was 1 instead of 0. (FastlaneCore::Interface::FastlaneShellError)

when set to use_adb_root: false there is no crash but I get a permission denied error when pulling the screenshot folder. Running the automated_test_emulator_run plugin as adb root might solve the problem. What do you think about it?

automated_test_emulator_run(
    AVD_setup_path: "fastlane/avd_api29_setup.json",
    AVD_recreate_new: false,
    AVD_clean_after: false,
    shell_task: "fastlane uiTestsWithScreenshots"
)
lane :uiTestsWithScreenshots do
    gradle(task: "assembleDebug assembleAndroidTest")
    screengrab(
        locales: ['en-US'],
        ending_locale: 'en-US',
        use_adb_root: true,
        clear_previous_screenshots: true,
        app_package_name: "com.littlepay.android.sdk.sample",
        app_apk_path: "sample/build/outputs/apk/debug/sample-debug.apk",
        tests_apk_path: "sample/build/outputs/apk/androidTest/debug/sample-debug-androidTest.apk"
    )
end