Search code examples
selenium-webdriverwebdriverappiumqaf

Qmetry- How to use appium driver


In QMetry, I am trying to switch from appiumDriver to androidDriver in one of test case. This need arised due to one of the function driver.isKeyboardShown() is showing as undefined for the appium. So need to change it to androidDriver and use this function.

Currently in Qmetry project, for appiumDriver capabilities are set in application.properties file as :

driver.name=appiumDriver
appium.capabilities.driverClass=io.appium.java_client.AppiumDriver

& using driver in test case as:

AppiumDriver driver = (AppiumDriver) new WebDriverTestBase().getDriver().getUnderLayingDriver();

Now want to switch to androidDriver.

Not sure how to switch from AppiumDriver to androidDriver in run time through java code.

How can I achieve this through code? Please suggest.


Solution

  • You should be able to cast it to AndroidDriver when using Android Driver.

    driver.name=appiumDriver
    appium.capabilities.driverClass=io.appium.java_client.android.AndroidDriver;
    

    Both of below statements should work:

    AppiumDriver driver = (AppiumDriver) new WebDriverTestBase().getDriver().getUnderLayingDriver();
    
    AndroidDriver driver = (AndroidDriver) new WebDriverTestBase().getDriver().getUnderLayingDriver();