To achieve parallel execution, I am updating my existing Junit project to TestNG. The requirement here is to run one scenario in different browsers using TestNG

RunnerClass is as follows:

import org.junit.runner.RunWith;
import org.testng.annotations.Test;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;

        format   = {"pretty","html:target/cucumber", "json:target/cucumber.json","rerun:target/rerun_featureName.txt"},
        features = {"src/test/resources/com.philips.rs.testcases.sanity.ui.features/02_adUserLogin.feature"},                               
        strict = true,
        monochrome = true,
        glue = {"com.philips.rs.ui.stepdefs","com.philips.rs.backend.stepdefs","com.philips.rs.utils"},
        tags = {"@rsUITest","@sanity",}


public class PBPRunnerSanityUITest extends AbstractTestNGCucumberTests {


The class where browser parameter is fetched.

public class WebDriverFactory {

    public static WebDriver driver = null;
    public static String currentBrowser = null;
    final static int TIMEOUT1 = 30;
    final static int TIMEOUT2 = 90;
    final static int TIMEOUT3 = 120;

    public static WebDriver createDriver(String browser) throws InterruptedException, MalformedURLException, IOException {

        currentBrowser = browser;
        DesiredCapabilities capabilities = new DesiredCapabilities() ;

        switch (browser) {

        case "IE_LOCAL":
            capabilities = DesiredCapabilities.internetExplorer();
            capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
            driver = new InternetExplorerDriver(capabilities);
        case "IE_REMOTE":

        case "CHROME_LOCAL":
            driver = new ChromeDriver();
        case "FIREFOX_LOCAL":       
            System.setProperty("webdriver.gecko.driver", "./driver_exe/geckodriver.exe");   
            FirefoxProfile profile = new FirefoxProfile();
            profile.setPreference("browser.download.folderList", 1);
            profile.setPreference("browser.download.manager.showWhenStarting", false);
            profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf,image/png,image/gif,application/json;charset=UTF-8,application/octet-stream; charset=utf-8,application/font-woff,text/csv");
            profile.setPreference( "pdfjs.disabled", true );
            capabilities.setCapability(FirefoxDriver.PROFILE, profile);
            driver = new FirefoxDriver(capabilities);
        case "CHROME_REMOTE":
            Runtime.getRuntime().exec("cmd /c start .\\batchFiles\\seleniumServer.bat");
            String nodeURL = "";
            capabilities = DesiredCapabilities.chrome();
            driver=new RemoteWebDriver(new URL(nodeURL), capabilities);         

        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

        return driver;

    public WebDriver getDriver()
        return driver;


TestNG XML file looks as below :

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

<suite name="Suite" parallel="tests">

  <test name ="FirefoxTest">
  <parameter name= "browser" value ="firefox"/>
      <class name="com.philips.rs.application.setup.PBPRunnerSanityUITest"/>

    <test name ="IETest">
  <parameter name= "browser" value ="ie"/>
      <class name="com.philips.rs.application.setup.PBPRunnerSanityUITest"/>


I am not able to able to fetch parameter value "Browser" in webDriverFactory Class, when Test is ran, code is not reached till WebDriverFactory . Please let me where it is going wrong.

2 Answers 2


It seems, there is no reference to WebDriverFactory anywhere, therefore its code is ignored.

You could try modifying PBPRunnerSanityUITest.java like this:

public class PBPRunnerSanityUITest extends WebDriverFactory {


And then update WebDriverFactory.java like this:

public class WebDriverFactory extends AbstractTestNGCucumberTests {

I tried with same code provided, executed fine for me with out any exceptions. How did you create the testng.xml file? If written manually, try the below instead:

  1. Right Click on src (or required package) in Eclipse
  2. Move to TestNG
  3. Select Convert to TestNG
  4. Click on Finish (you can provide names for suite and test here)

Open the created testng.xml file, using parallel="false"

Now run the testng.xml file. Also, try to avoid naming conventions with reserved words like DataProvider, TestNG etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.