Search code examples
androidmobileautomationappium

AutoGrantPermissions not working with Andriod 10 and 11 with Appium 1.18.3


I'm currently working on test automation with Appium and android emulators.

Appium Details:

App Version 1.18.3
Electron: 7.2.4
Node.js: 12.8.1

Emulator Details


Name: Pixel 2 Q 10.0 - API 29
OS: Q 10.0 - API 29
Processor: x86
Memory: 1GB
Resolution: 1080x1920 420 dpi

Desired Capabilities set in the script

app_file_path = "https://.../selendroid-test-app.apk"
platform_version = "10.0"
platform_name = "Android"
appium_port = "4723"
device_name = "Android Emulator"

desired_caps = {  
    caps: {
      automationName: "UIAutomator2",
      app: app_file_path,
      platformName: platform_name,
      platformVersion: platform_version,
      deviceName: device_name,
      newCommandTimeout: 3600,
      autoGrantPermissions: true
    },
    appium_lib: {
      port: appium_port
    }
  }

  driver = Appium::Driver.new(desired_caps).start_driver

On running this ruby script, I observe that the screen on emulator shows up the following and blocks my automation. Is there any other way to bypass this screen as it blocks automation. Many of them who experienced this error solved this by setting autograntpermissions to true. However, this does not work for me with android emulators with version 10 and 11. [Emulator screenshot][1] [1]: https://i.sstatic.net/9fS47.png

Please let me know how to solve this.


Solution

  • I was able to solve this by setting fullReset to true in the desired capabilities. Now my desired capabilities are as follows

    desired_caps = {  
        caps: {
          automationName: "UIAutomator2",
          app: app_file_path,
          platformName: platform_name,
          platformVersion: platform_version,
          deviceName: device_name,
          newCommandTimeout: 3600,
          autoGrantPermissions: true,
          fullReset: true
        },
        appium_lib: {
          port: appium_port
        }
      }