Search code examples
seleniumtestngappiumqaf

How to configure one test in TestNG XML file to start two driver, like Chrome Driver and Android Driver when using QAF


Case Step:

  1. Open an web browser to do some step
  2. Open Android device with Appium to do some step.

Note: Those two steps should be run in one test of TestNG XML.


Solution

  • If you don't want both driver session be active but want to switch to another driver by kill current driver session you can set driver.name property in code and it will do the needful. Changing any of following property in code teardowns existing driver and creates new driver instance:

    driver.name
    driver.additional.capabilities
    remote.server
    remote.port
    

    For example:

    getBundle().setProperty("driver.name","chromeDriver");
    //do the needful
    
    
    getBundle().setProperty("driver.name","anotherDriver");
    //it will teardown chromedriver and create anotherDriver session in next driver call.
    //do the needful
    

    If you want to have both driver session to be active, Support for Multiple driver in the same thread/test-case has been added since 2.1.11. To change driver within test case you can use setDriver(String driverName) method of QAFTestBase. For instance:

    TestBaseProvider.instance().get().setDriver("chromeDriver");`
    

    Refer details in commit notes.