Native to Chrome browser


#1

I am automating android native app and i am stuck in one situation.

Steps :
1 launching native from appium in android phone.
2 There i am clicking on a button which opens the separate chrome browser in android not the inbuild hybrid view
3 So now i have to work on that browser in android.
4 how can i switch to that browser after clicking the link from native app android

What i have tried
1 Tried to switch the context.
Set allContext = appiumDriver.getContextHandles();

    for (String context : allContext) {
        if (context.contains("WEBVIEW_chrome")) {
            appiumDriver.context(context);
            return true;
        }
    }

Exception : An unknown server-side error occurred while processing the command. Original error: No Chromedriver found that can automate Chrome ‘58.0.3029’. See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md for more details. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’

2 Using start activity

	Activity activity = new Activity("com.android.chrome", "com.android.chrome.app.Main");
    AndroidDriver appiumDriver=(AndroidDriver) testContext.getWebDriver(logger);
    appiumDriver.startActivity(activity);

Note : I am not talking about chrome browser within native app.
My chrome browser is opening separately after clicking link from my android native app.

Also please let me know same is possible in iOS or not ?


#2

I don’t know the proper way to solve it, but I can suggest a workaround. Try to initialize the browser session instead of applicaion session - specify browserName: “Chrome” in capabilities. Then in your test firstly switch to native app context and click on your button. After page loads, switch back to CHROMIUM. It should work.


#3

i have to switch from native app to chrome browser.

I click on a link in my native app which opens chrome browser.