public abstract class WComponentSeleniumTestCase extends Object
An abstract class which provides convenience methods to test the UI using Selenium to drive a web browser.
The implementation of various features (ServerCache, WebDriverCache) has been extracted out to static utility classes for applications that cannot extend this class for tests.
| Constructor and Description |
|---|
WComponentSeleniumTestCase()
Creates a WComponentSeleniumTestCase.
|
WComponentSeleniumTestCase(boolean useDefaultDriver)
Creates a WComponentSeleniumTestCase.
|
WComponentSeleniumTestCase(boolean useDefaultDriver,
String url)
Creates a WComponentSeleniumTestCase.
|
WComponentSeleniumTestCase(WebDriverType driverType)
Creates a WComponentSeleniumTestCase with the given driver type.
|
WComponentSeleniumTestCase(WebDriverType driverType,
String driverId)
Creates a WComponentSeleniumTestCase with the given driver type.
|
WComponentSeleniumTestCase(WebDriverType driverType,
String driverId,
String url)
Creates a WComponentSeleniumTestCase with the given driver type.
|
| Modifier and Type | Method and Description |
|---|---|
SeleniumWComponentsWebDriver |
getDriver()
Retrieves the current driver instance, launching it for the URL if it is not already running.
|
SeleniumWComponentsWebDriver |
getDriverWithoutLaunching()
Retrieve the driver without launching it.
|
String |
getUrl() |
void |
setDriver(WebDriverType driverType,
String driverId)
Set the driver type and ID for this test.
|
void |
setUrl(String url)
Set the URL to use for the test.
|
public WComponentSeleniumTestCase()
Creates a WComponentSeleniumTestCase.
Most tests should use this constructor to get the default WebDriverType.
public WComponentSeleniumTestCase(boolean useDefaultDriver)
Creates a WComponentSeleniumTestCase.
Most tests should use a 'true' value to get the default WebDriverType.
The driver will be launched if the driverType is set and the Url is set or configured.
Tests using the MultiBrowserRunner must use a 'false' parameter so the creation is deferred until the test is run.
useDefaultDriver - - if true, a default ParameterizedWebDriverType will be used. If false, the driver must
be set after the constructor.public WComponentSeleniumTestCase(boolean useDefaultDriver,
String url)
Creates a WComponentSeleniumTestCase.
Most tests should use a 'true' value to get the default WebDriverType.
A non-null URL parameter specifies that the server has already been launched at the given URL.
The driver will be launched if the driverType is set and the Url is set or configured.
Tests using the MultiBrowserRunner must use a 'false' parameter so the creation is deferred until the test is run.
useDefaultDriver - - if true, a default ParameterizedWebDriverType will be used. If false, the driver must
be set after the constructor.url - the url of the server. A non-null URL will prevent a server from being launched.public WComponentSeleniumTestCase(WebDriverType driverType)
Creates a WComponentSeleniumTestCase with the given driver type.
The driver will be launched if the driverType is set and the Url is set or configured.
driverType - the type of WebDriver to use.public WComponentSeleniumTestCase(WebDriverType driverType, String driverId)
Creates a WComponentSeleniumTestCase with the given driver type.
The driver will be launched if the driverType is set and the Url is set or configured.
driverType - the type of WebDriver to use.driverId - - the id to use to separate multiple instances of the same driver.public WComponentSeleniumTestCase(WebDriverType driverType, String driverId, String url)
Creates a WComponentSeleniumTestCase with the given driver type.
A non-null URL parameter specifies that the server has already been launched at the given URL.
driverType - the type of WebDriver to use.driverId - - the id to use to separate multiple instances of the same driver.url - the url of the server. A non-null URL will prevent a server from being launched.public void setDriver(WebDriverType driverType, String driverId)
Set the driver type and ID for this test.
Use a null driverId if not using multiple drivers of the same type.
driverType - the WebDriverType to use.driverId - OPTIONAL the driver Id to use.public void setUrl(String url)
url - the URL to set.public String getUrl()
public SeleniumWComponentsWebDriver getDriver()
Retrieves the current driver instance, launching it for the URL if it is not already running. Subclasses should use this to obtain a driver instance for their tests. Note that the driver is retained between tests unless explicitly closed.
If not already running, the driver will attempt to load the configured Url. An exception will be thrown if the driver or URL is not configured.
public SeleniumWComponentsWebDriver getDriverWithoutLaunching()
Retrieve the driver without launching it.
An exception will be thrown if the driverType has not been configured.
Copyright © 2016. All rights reserved.