Appium Switching between native app to chrome browser throws Error

Hi
appium automation with [email protected]

I have an native app running. Now i am trying to open a Mobile Chrome browser
I am using the following code suggested by you from some other query

((AndroidDriver) driver).startActivity(new Activity(“com.android.chrome”, “com.google.android.apps.chrome.Main”));

Problem comes only - on a new android device … If i use the code then the mobile chrome browser is not loading. But if i run it post if i open a browser manually its working fine. So this issue with with 1st time browser loading.

I have this challage of 1st time error on android mobile browser because i am using AWS Device Farm which boots or allocates newer machine with every run so my chrome broswer never loads

Here is the error for the above code and capabilities being used

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot start the ‘com.android.chrome’ application. Consider checking the driver’s troubleshooting documentation. Original error: ‘com.google.android.apps.chrome.Main’ or ‘com.android.chrome.com.google.android.apps.chrome.Main’ never started. Consider checking the driver’s troubleshooting documentation.

Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’

System info: host: ‘Mac-Q02H7RH7’, ip: ‘fe80:0:0:0:468:d114:c3e4:f4e8%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.16’, java.version: ‘1.8.0_171’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {app: /Users/x287202/SouthWest/ap…, app:setWebContentsDebuggingEnabled: true, appPackage: com.swalife.crewhub.qa, autoAcceptAlerts: true, autoWebView: true, autoWebviewTimeout: 100, automationName: uiautomator2, databaseEnabled: false, desired: {app: /Users/x287202/SouthWest/ap…, app:setWebContentsDebuggingEnabled: true, autoAcceptAlerts: true, autoWebView: true, autoWebviewTimeout: 100, automationName: uiautomator2, fullContextList: true, newCommandTimeout: 180, platformName: android}, deviceApiLevel: 33, deviceManufacturer: Google, deviceModel: sdk_gphone64_arm64, deviceName: emulator-5554, deviceScreenDensity: 420, deviceScreenSize: 1080x2400, deviceUDID: emulator-5554, fullContextList: true, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, newCommandTimeout: 180, pixelRatio: 2.625, platform: LINUX, platformName: Android, platformVersion: 13, statBarHeight: 63, takesScreenshot: true, viewportRect: {height: 2274, left: 0, top: 63, width: 1080}, warnings: {}, webStorageEnabled: false}

Hi,
Appreciate any update on this issue.

Possible reason after my analysis and debut might be

  • When the chrome is loaded via aap and package activity on a new device, the chrome comes up with few welcome screen.
  • On those screens chrome expects user intervenion.
    startActivity(new Activity(“com.android.chrome”, “com.google.android.apps.chrome.Main”))
    Debugger hangs on the above line. So chrome loading is never completes and its times out while expecting user input.

So a possible solution might be a way to avoid chrome welcome messages if there is a way to do so via appium?
I may be wrong with this analysis but kindly suggest?