How do I run a script in different browsers in Parallel

I attempt to run various browsers(IE, Chrome, FF) in parallel using TestNG but unable to the script running. Below is my script..

package TestNG;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterClass;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import com.beust.testng.*;
import org.testng.annotations.Test;

public class qabrowsers {

private WebDriver driver;

// Configure for multi browser drivers
public void beforeTest(String browser) {
if (browser.equalsIgnoreCase(“firefox”)) {
driver = new FirefoxDriver();
} else if (browser.equalsIgnoreCase(“chrome”)) {
// Set Path for the executable file
driver = new ChromeDriver();
} else if (browser.equalsIgnoreCase(“ie”)) {
// Set Path for the executable file
System.setProperty(“”, “C:\\Selenium\\IEDriverServer.exe”);
driver = new InternetExplorerDriver();

} else {
throw new IllegalArgumentException(“The Browser Type is Undefined”);
// Open App

public void afterTest() {
try {
} catch (Exception e) {
driver = null;

My xml….

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE suite SYSTEM “”>

<!–Change The Parallel attribute for parallel Execution–>
<suite name=”Suite” parallel=”tests”>

<test name=”FirefoxTest”>
<parameter name=”browser” value=”firefox” />
<class name=”qabrowsers.qabrowsers” />

<test name=”ChromeTest”>
<parameter name=”browser” value=”chrome” />
<class name=”qabrowsers.qabrowsersTest” />

<test name=”IETest”>
<parameter name=”browser” value=”ie” />
<class name=”qabrowsers.qabrowsersTest” />


Train Asked on December 18, 2014 in Selenium WebDriver.

<class name=”qabrowsers.qabrowsersTest” /> i think there is some problem in this line
<class name=”address to class starting from package”/>

i guess in your case it should be
<class name=”TestNG.qabrowsers “/>
and i dnt think you have test case in that class what u have before and after class

on December 19, 2014.
Add Comment
  • 1 Answer(s)


    There is problem in your testng xml , you should run your classes as parallel rather then test and you are using @BeforeClass

    Supporter Answered on December 23, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.