Parallel Execution using TestNG
For Parallel execution ,we will be working on 3 different components as below: A Factory class that will create WebDriver instances A Manager class that can be accessed to retrieve a WebDriver instance A TestNG listener that will be responsible for instantiating the WebDriver instance automatically First we will create a Factory class which will create and return the desired webdriver object: package execution.parallel; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.ie.InternetExplorerDriver; class LocalDriverFactory { static WebDriver createInstance(String browserName) { WebDriver driver = null ; if (browserName.toLowerCase().contains( "firefox" )) { driver = new FirefoxDriver(); return driver; }