1) Create TestNG class.
package com.software.testing;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TC1 {2) Now Create testng.xml file into your project folder
WebDriver driver;
@Test
public void firstTestCase() {
// Printing Id of the thread on using which test method got executed
System.setProperty("webdriver.chrome.driver", "Your Driver Path");
driver = new ChromeDriver();
driver.get("https://www.google.com");
}
}
<suite name="ParallelTestingGoogle" verbose="1" parallel="tests" thread-count="5">
<test name="1stExecution">
<classes>
<class name="com.software.testing.TC1"></class>
</classes>
</test>
<test name="2ndExecution">
<classes>
<class name="com.software.testing.TC1" />
</classes>
</test>
<test name="3rdExecution">
<classes>
<class name="com.software.testing.TC1" />
</classes>
</test>
<test name="4thExecution">
<classes>
<class name="com.software.testing.TC1" />
</classes>
</test>
<test name="5thExecution">
<classes>
<class name="com.software.testing.TC1" />
</classes>
</test>
</suite>
Note : Don't forget to specify parallel="tests".
When you run your testNg suite it will open five chrome window and run your test case parallel.