How to use Appium Driver AND WebDriver to test devices and web in the same framework


I have managed to successfully set up my java framework using Appium to test devices thanks to the help of several people on this site.

I now want to extend the framework so that it can test a website as well. Some tests will run on devices and some will run on web. No test will run on BOTH device and web - it is one of the other.

The way I have currently set this up is to create TWO different drivers as shown below:

public static AppiumDriver appDriver = null;
public static WebDriver webDriver = null;

I use the AppiumDriver for testing the devices and the WebDriver for testing web.

Is this the right way to do it or should I start off with ONE RemoteWebDriver and CAST it to AppiumDriver or WebDriver as required by the test?


Anyone got any thoughts on this?

Currently if the test runs on a device it uses appDriver and if it runs on the web it uses webDriver.

However this causes problems for shared methods such as driver.quit…I have to have more code to handle both types of driver…(e.g. if device test appDriver.quit, if web webDriver.quit).

Is there a way to just declare one driver (called driver) that can be cast to Appiumdriver or Webdriver as required by the test?

I could then use driver.quit and this would work regardless of whether the test is a device test or a web test?

Thanks for any help.

I think it is the best idea to have two separate objects. You’ll get too many problems if you merge them.

1 Like