Created
August 28, 2017 02:20
-
-
Save JitendraZaa/6f91c6d0a33e01663b56660796684821 to your computer and use it in GitHub Desktop.
Parallel execution of browsers in Selenium with the help of TestNG and determining maximum operating capacity of custom code in Salesforce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.jitendrazaa; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
public class DriverFactory | |
{ | |
private DriverFactory() | |
{ | |
//Do-nothing..Do not allow to initialize this class from outside | |
} | |
private static DriverFactory instance = new DriverFactory(); | |
public static DriverFactory getInstance() | |
{ | |
return instance; | |
} | |
ThreadLocal<WebDriver> driver = new ThreadLocal<WebDriver>() // thread local driver object for webdriver | |
{ | |
@Override | |
protected WebDriver initialValue() | |
{ | |
return new ChromeDriver(); // can be replaced with other browser drivers | |
} | |
}; | |
public WebDriver getDriver() // call this method to get the driver object and launch the browser | |
{ | |
return driver.get(); | |
} | |
public void removeDriver() // Quits the driver and closes the browser | |
{ | |
driver.get().quit(); | |
driver.remove(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment