0

In My UI-Tests Framework I have 5 webdriver tests and currently running only in firefox browser.

I need to run my tests in chrome & firefox multiple versions.

We have a browser stack license to use RemoteWebdriver to run against multiple browser versions for chrome & firefox.

1)How should I create the driver instance in BeforeMethod or BeforeClass? 2)How should I iterate all browser combinations lets say for Firefox 45,46, Chrome 51,52 from a single maven target mvn test one by one (browser? 3)How to skip a test for one specific browser (firefox 45, not in chrome 51) version?

How should I design my framework? Any suggestions. Many Thanks!

sudarson
  • 43
  • 1
  • 7
  • Instead of creating your own framework or spending time in reinventing the wheel, you can start using any of available proven frameworks. – user861594 Oct 07 '16 at 16:18

2 Answers2

1

It's all depending on your implementation. We are using open source QMetry Automation Framework to achieve parallel execution and configuration. It has driver configuration outside the code. For example:

<suite name="AUT Test Automation" verbose="0" parallel="true">
      <parameter name="brand.name" value="westin" />
      <parameter name="target.platform" value="mobile" />
      <test name="Mobile Web Tests on IPhone">
            <parameter name="remote.server" value="10.12.49.180"/>
            <parameter name="remote.port" value="3001" />
            <parameter name="driver.name" value="iphoneRemoteDriver" />           
            ...
      </test>
      <test name="Mobile Web Tests on android">
            <parameter name="remote.server" value="10.12.48.87"/>
            <parameter name="remote.port" value="8080" />
            <parameter name="driver.name" value="androidRemoteDriver"/>                      
            ...
      </test>
 </suite>

Refer detailed documentation for more information.

  • yes, Also you don't required to use BeforeMethod or BeforeClass to create the driver instance, just extend webdriver test base and use getDriver() method instead. For driver combination you can do in XML configuration file. – user861594 Oct 07 '16 at 16:12
  • Thank @java_automation for your thoughts! Is there a way using Selenium Factory to solve this by running test class multiple time? – sudarson Oct 10 '16 at 13:13
  • even if you use any implementation of factory still you need to struggle for thread safe sessions and setting different capabilities/browser for different parallel threads. With QMetry Automation Framework all such implementation is ready to use. [refer](https://qmetry.github.io/qaf/qaf-2.1.8/setting_driver_capabilities.html) –  Oct 14 '16 at 05:12
  • You also can refer [running-selenium-webdriver-tests-on-cloud-using-qaf](http://stackoverflow.com/questions/39669551/running-selenium-webdriver-tests-on-cloud-using-qaf) –  Oct 14 '16 at 05:18
0

If you don't want to run different browser parallely. Then you can use Cucumber to write you automation test.

Cucumber allows you to right Scenario Outline, which you can use in this way.

test.feature

Feature: test different browser
Scenario Outline:test
  GIVEN I select <browser>
  WHEN I do something
  THEN i get some result
Examples:
|browser|
|chrome|
|firefox|

Above was a feature file for which you can create step file which contain step definitions. Something like below

stepfile.java

@Given("^I select (.+)")
   public void selectBrowser(String browser) throws Throwable {
     if(browser.equals("chrome")){
      driver = new ChromeDriver();
       }
     else if(browser.equals("firefox")){
      driver = new FirefoxDriver();
       }
     else{
       }
  }