0

I'm working in a big project, i want to run eature cucumber in parallel in different browser I have the featuren the step definition ? the webdriverfactory and the shared preferences.

I have this method in webfactory and it works and i write the testng.xml

 public WebDriver driver;
    public static WebDriver get() {
          WebDriver driver = null ;
        System.setProperty("webdriver.chrome.driver","D:\\Drive\\chromedriver_win32\\chromedriver.exe");
        driver= new ChromeDriver();
        return(driver);
    }


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name="SuiteSopraHR" parallel="tests">


      <test  name="testie">
    <!--   <parameter name="myBrowser" value="ie" /> -->
        <classes>
          <class name="com.driver.WebDriverFactory"/>
        </classes>
      </test> <!-- Test -->


        <test  name="testchrome">
    <!--   <parameter name="myBrowser" value="chrome" /> -->
        <classes>
          <class name="com.driver.WebDriverFactory"/>
        </classes>

      </test> <!-- Test -->
    </suite> <!-- Suite -->

I don't know how to change the other method because it didn't has any parameter to pass and it return a web driver. when I have changed all the other method in other classes have a problem with it any suggestion please. and is the cucumber-jvm can run feature in parallel in different browser ??? or in console ???

user6618310
  • 39
  • 1
  • 5
  • 14

3 Answers3

2

You can indeed run Cucumber features and scenarios in parallel using Courgette-JVM

When you run your tests, you can set a System property that would target the browser you wish to use in parallel.

Another useful library to manage your driver binaries is WebDriver Binary Downloader

You can then specify the browser to use at runtime using:

System.setProperty("browser", "chrome");

or

VM option -Dbrowser="chrome"

private WebDriver driver;

public void createDriver() {
    final String browser = System.getProperty("browser", "chrome").toLowerCase();

    switch (browser) {
        case "chrome":
            WebDriverBinaryDownloader.create().downloadLatestBinaryAndConfigure(BrowserType.CHROME);
            driver = new ChromeDriver();

        case "firefox":
            WebDriverBinaryDownloader.create().downloadLatestBinaryAndConfigure(BrowserType.FIREFOX);
            driver = new FirefoxDriver();

        default:
            throw new RuntimeException("Invalid browser specified!");
    }
}
  • Is this help to to run my feature in different browser chrome and ie in parallel or just in one browser ? i used cucumber JVM to run different features in the same browser – user6618310 Apr 06 '18 at 09:40
  • Both browsers at the same time. All you will need is to create 2 runner classes. Then execute both runner classes at the same time. – Prashant Ramcharan Apr 06 '18 at 09:42
  • In fact, all you will need is create 1 runner class and simple run it twice but set the System property (example: run1, you pass -Dbrowser=chrome AND run2, you pass -Dbrowser=ie) – Prashant Ramcharan Apr 06 '18 at 09:47
1

We are using QAF-Gherkin-client, where you can configure it using one or more xml test nodes. You can run scenarios in parallel as well. You don't need to write any code for driver management or other functional testing common needs.

<suite name="AUT Test Automation" verbose="0" parallel="methods">
      <test name="Tests on chrome">
            <parameter name="driver.name" value="chromeDriver"/>         
            <classes>
                  <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
            </classes>
      </test>
      <test name="Tests FF">
            <parameter name="driver.name" value="firefoxDriver"/>         
            <classes>
                  <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
            </classes>

      </test>
 </suite>
user861594
  • 5,733
  • 3
  • 29
  • 45
0

I think, you need to add switch construction in your method and parameter - type of browser from testng.xml. Also, as I know, parallel execution will work only with a non-static Driver.

Ukrainis
  • 534
  • 2
  • 16