Parameterization And Parallel Execution Of The Script Using TestNG
Posted By : Kuldeep Sidana | 30-Jan-2018
- Executing the scripts parallely using TestNG suite file is called Parallel Execution.
- Executing the scripts with the multiple browsers is called cross browser testing.
- To achieve cross browser testing we introduce parallel execution using TestNG.
- Using TestNG theoretically we can execute five browser but practically we can execute three browsers parallely.
Code for Parallel Execution
/**
*
* @author Kuldeep Sidana
*/
public class ParametrizationTest {
public WebDriver driver ;
@BeforeMethod
@Parameters(value="browser")
/**
* @param browser
*/
public void preCondition(String browser)
{
if(browser.equalsIgnoreCase("firefox"))
{
driver = new FirefoxDriver();
Reporter.log("firefox launched",true);
}
else if (browser.equalsIgnoreCase("chrome"))
{
System.setProperty("webdriver.chrome.driver",".\\exefiles\\chromedriver.exe");
driver = new ChromeDriver();
Reporter.log("chrome launched",true);
}
else if(browser.equalsIgnoreCase("IE"))
{
System.setProperty("webdriver.ie.driver",".\\exefiles\\chromedriver.exe");
driver = new InternetExplorerDriver();
Reporter.log("IE launched",true);
}
else
{
driver = new FirefoxDriver();
Reporter.log("IE launched",true);
}
driver.manage().window().maximize();
driver.get("http://dev.kairosplanning.com");
Reporter.log("Navigating to url", true);
WaitStatementLib wLib = new WaitStatementLib();
wLib.implicitWaitForSeconds(driver, 10);
}
@Test public void FBlogin() throws InterruptedException {
driver.findElement(By.id("userName")).sendKeys("[email protected]");
driver.findElement(By.id("password")).sendKeys("ulk@123");
Thread.sleep(2000);
driver.findElement(By.xpath("//input[contains(@value,'VERIFY')]")).click();
System.out.println("login successfully");
}
@AfterMethod
public void afterTest() {
driver.quit();
}
}
-
Parameter value is passed as an argument in suit file.
XML Suit File
Request for Proposal
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Kuldeep Sidana
Kuldeep Sidana is an orient QA Engineer having dexterity in Core Java and vouched with Automation Testing tool (Selenium Web Driver) and Manual Testing.