Search code examples
appiumappium-iosandroid-auto

Regarding drivers in mobile app automation


For automating android app I am using AppiumDriver

 AppiumDriver driver = new AppiumDriver(new URL("http://localhost:5555/wd/hub"), capabilities);

I have found in web using RemoteWebDriver

 RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:5555/wd/hub"), capabilities);

Is there any need for using different drivers. If yes,for automationg iOS app which driver I need to use?


Solution

  • There are multiple possibilities for what driver to use and the difference is how much platform specific features you wish to have available.

    For Android the most specific driver would be AndroidDriver. AndroidDriver extends AppiumDriver (the one you're using right now) and AppiumDriver extends RemoteWebDriver. In other words, RemoteWebDriver has least features and going one level further with a driver brings more choices.

    Java-client's AndroidDriver: http://appium.github.io/java-client/io/appium/java_client/android/AndroidDriver.html

    Inheritance of AndroidDriver as seen in the API documentation page:

    java.lang.Object
      org.openqa.selenium.remote.RemoteWebDriver
        io.appium.java_client.AppiumDriver<T>
          io.appium.java_client.android.AndroidDriver<T>
    

    Note that AppiumDriver and AndroidDriver include the <T>, which allows you to choose what type of MobileElements you're using. To access all Android specific features of the driver, you may want to define <T> to <AndroidElement>: http://appium.github.io/java-client/io/appium/java_client/android/AndroidElement.html

    Inheritance of AndroidElement:

    java.lang.Object
      org.openqa.selenium.remote.RemoteWebElement
        io.appium.java_client.MobileElement
          io.appium.java_client.android.AndroidElement
    

    iOS has similarly IOSDriver: http://appium.github.io/java-client/io/appium/java_client/ios/IOSDriver.html With inheritance of:

    java.lang.Object
      org.openqa.selenium.remote.RemoteWebDriver
        io.appium.java_client.AppiumDriver<T>
          io.appium.java_client.ios.IOSDriver<T>
    

    In many cases it's enough to simply use the AppiumDriver together with <WebElement> (this is used by default) or <MobileElement>