0
votes

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 ???

3

3 Answers

1
votes

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!");
    }
}
0
votes

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.

0
votes

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>