Two driver In a single session

I want to create android driver and web driver in a single session … it is nt allowing to create both .
Can someone help me as I ned to verify app functionality on a dashboard .

U cannot have two driver sessions for sure.

Why do u need a webdriver, as Android driver it sub-class of a webdriver

Why couldn’t you have two driver sessions? They are just two separate objects within your test. One connecting to appium hub and one connecting to a webDriver Hub. You will have to name them differently, build the connections separately, and manage the state between your two drivers, but this isn’t difficult. We’ve done this many times with our automation framework at Applause.

1 Like

Hi actually I ned two drivers as when I wil b performing actions on my app through phone and ned to cross check it on a web browser dashboard for the responses.

I want both in a single session
It’s giving a null pointer whenever I am creating web driver in the mid of test case already having a appium driver in it

Well, this is possible indeed.
Just declare alternate WebDriver webDriver instance and do everything you want to do on web.
I’ve done this way when I had to test web chat functionality, and this was working for me.

I want both in a single session

Well, “as you wish”, but there is no “technical reason” to do this exactly on this way (I guess)

I will try it again
First I had created an appium driver n than for web driver it is giving a null pointer.

You’re not reusing the driver object are you?

WebDriver driver = new AppiumDriver(); //crude example
//do stuff on mobile app
driver = new FirefoxDriver();

In a two driver single session case, it would be preferable to have 2 separate driver instances, in the event you need to switch back and forth between the drivers in your test (do stuff here do stuff there do stuff here again, etc.) instead of reassigning the single driver object instance to a different type of driver.

A null pointer issue wouldn’t have to do anything with Appium, unless the Appium one is throwing the null pointer. So it would likely be a Selenium WebDriver problem instead. Which Selenium driver are you invoking?

I’ve done dual drivers in same session before but not with Appium, shouldn’t matter though should work the same. P.S. my case was a proof of concept demo of WebDriver + AutoItDriverServer driver.

You can initialise two driver.

  1. For appium
  2. For web browser

thanks its working now by creating two drivers.

Great @akhilesh_gulati,

Can you post here some info regarding what you’ve achieved.?

How to create two driver objects in a best way :slight_smile:


Yes please post sample code snippet for 2 driver sessions

please share code im unable to create second driver.
im running appium programmatically

It would be really nice if anybody can share the code snippet. I also want to test the native android app and mobile chrome browser At the same time.