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.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
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
@Parameters(“browser”)
@BeforeClass
public void beforeTest(String browser) {
if (browser.equalsIgnoreCase(“firefox”)) {
driver = new FirefoxDriver();
} else if (browser.equalsIgnoreCase(“chrome”)) {
// Set Path for the executable file
System.setProperty(“webdriver.chrome.driver”,
“C:\\Selenium\\chromedriver.exe”);
driver = new ChromeDriver();
} else if (browser.equalsIgnoreCase(“ie”)) {
// Set Path for the executable file
System.setProperty(“webdriver.ie.driver”, “C:\\Selenium\\IEDriverServer.exe”);
driver = new InternetExplorerDriver();

} else {
throw new IllegalArgumentException(“The Browser Type is Undefined”);
}
// Open App
driver.get(“https://hyb-pre-prod-ca.oakley.com/”);
}

@AfterClass
public void afterTest() {
try {
driver.quit();
} catch (Exception e) {
driver = null;
}
}
}

My xml….

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

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

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

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

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

</suite>

jbfannie Train Asked on December 18, 2014 in Selenium WebDriver.

hi
<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)

Hi

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

kapilag Supporter Answered on December 23, 2014.
Add Comment

Your Answer

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