public final class WebDriverCache extends Object
Static utility testing class to keep a Selenium Web Driver open between tests using the same thread. This is to prevent the expensive WebDriver creation occurring multiple times per test suite.
WebDriver implementations are not thread-safe, so the drivers opened by this class will be separated from other threads via a ThreadLocal.
Multiple concurrent instances of the same driver type can be created using a different driver id.
This class will clean up open drivers when the JVM terminates.
| Modifier and Type | Method and Description |
|---|---|
static void |
closeDriver(WebDriverType driverType,
String driverId)
Close the driver of the given type and driver id.
|
static <T extends org.openqa.selenium.WebDriver> |
getDriver(WebDriverType<T> driverType)
Get or create the driver for the given driver type.
|
static <T extends org.openqa.selenium.WebDriver> |
getDriver(WebDriverType<T> driverType,
String driverId)
Get or create the driver for the given driver type and unique driver id.
|
static void |
releaseDriver(WebDriverType driverType,
String driverId)
Close the driver of the given type and driver id.
|
public static <T extends org.openqa.selenium.WebDriver> SeleniumWComponentsWebDriver<T> getDriver(WebDriverType<T> driverType)
T - the type of the WebDriver.driverType - the WebDriver type wrapper.public static <T extends org.openqa.selenium.WebDriver> SeleniumWComponentsWebDriver<T> getDriver(WebDriverType<T> driverType, String driverId)
T - the type of the WebDriver.driverType - the WebDriver type wrapper.driverId - the unique identifier for this driver implementation.public static void closeDriver(WebDriverType driverType, String driverId)
driverType - the type of the driver to close.driverId - the unique driver id of the driver to closepublic static void releaseDriver(WebDriverType driverType, String driverId)
driverType - the type of the driver to close.driverId - the unique driver id of the driver to closeCopyright © 2017. All rights reserved.