Can we use wedriver and appiumdriver in the same framework.So that Same framework can be used by both web as well as mobile application automation


We are having a framework,that is being developed for Web application Automation using selenium JAVA+Webdriver.Now We have expanded to Mobile automation as well.We want to use the same framework for Both.But we face issue with the driver.We are using APPIUM for Mobile Automation. The issue is with the driver. As Same driver can’t be used by WebDriver and APPIUMDriver.

Kindly Suggest.

You can use, because AndroidDriver is extends RemoteWebDriver which usually use for Web automation.

You can absolutely use same webdriver instance for both desktop and mobile runs. As Priyank_Shah rightly said since AppiumDriver is extending Webdriver we can achieve this. Sample code snippet might help you.

      WebDriver driver = getDriver(driverType); // webdriver instance to be passed on to test scripts

      //Method for instantiating driver object
      public WebDriver getDriver(driverType){
          switch (driverType) {

	       case Firefox :   return new FirefoxDriver();
               case Chrome:     return new ChromeDrviver();
               case IE :        return new InternetExplorerDriver();
               case Android :   return new AndroidDriver("",capabilitiesObject);

    Based on the driver type you can downcast your webdriver reference object and make calls to the respective api.