How to launch both native app and chrome browser on android to switch between them


Hi All,

Please clarify how to launch appium driver for both native and web view.

I need to test password reset flow for which I have to start from native -> webview -> native

Thanks in advance.



Hi @VikramVI

you can switch between context and test your password reset flow. Here is sample code.

Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
if (contextName.contains(“WEBVIEW”)){
// code to test password reset field.

// once done with password reset test again switch back to Native view


Hope this will help.

Ravi Kumar


These links can be helpful for better understanding.



Hi @ravikr42,

Thanks for quick reply, but I’m still not clear which capabilities to use to create driver object which can be used for both native app and browser operations ?

I tried searching but didn’t get clear answer. Kindly clarify

Thanks in advance.



Are you testing 2 different apps? or its a Hybrid app which contains both native and WebView? If its a hybrid app u can use single driver object for all operation.

Create a instance of AppiumDriver/AndroidDriver and proceed.

In capabilities part you just need to supply basic device and platform details with app package and app activity.



Hi @ravikr42 Thanks for reply, it’s a native app.
I want to test password reset flow with it.
For this first I need to launch native app, later web view ( chrome browser on android ) and come back to native app.

I am not understanding how to launch chrome browser and native app at same time so that I can switch context between them ?

If you can please share sample code, it will be helpful.

thanks & regards,


Hello Vikram,
You can use two instances of AppiumDriver. One for NATIVE application and another for ChromeBrowser.

driver1=new AppiumDriver();
driver2 = new AppiumDriver();

so that you can perform the operations independently on both driver instances :slight_smile:


Hi @sachin925,

Thanks a ton for reply, I was wondering if actions on 2 apps is possible at all with single driver instance.

I’ll try this and update back on this thread.

Thanks & Regards,


Hi @VikramVI,

Always welcome :slight_smile:

How to write a code to click on forgot password link which is sent to mail Id switch back to native app in ios

Just to update on this topic so it’ll be useful to others as well.

I could achieve “Password Reset” flow in below steps

  1. Create Android App driver and initiate password reset. Stop this driver
  2. Create Chrome Browser driver and finish password reset flow. Stop this driver
  3. Create Android App driver and login to app with new password.

This flow takes around 2 m 10 sec on Nexus 5 + Chrome browser


Hi @VikramVI

Did u launch the pre install chrome browser app on your device, I am trying to launch the app on Android device having OS 7.0. Welcome screen of chrome gets displayed all the time whenever I launch the chrome browser app.

Can you please share your experience, how u achieved it



hello every one i am facing the same kind of problem , i want to test Browser links on native app , when i clicked on links from native app then broswer is opened but from browser i want to check wehter this link is matched with my expected result below is my code can anyone to figure out the problem

@Test(priority = 10)//Validate that FaceBook Link is working Fine
public void ValidateFacebookLink() throws MalformedURLException, InterruptedException {
WebElement FaceBookLinkID = driver
// CherryPikLaunchInBrowser();


public void chromeBrowser() throws InterruptedException {
Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
if (contextName.contains(“WEBVIEW”)){
String ActualURL=driver.getCurrentUrl();