public interface ThreadWebDriverMap
This is necessary because Cucumber doesn't really support the notion of running tests in multiple threads with multiple configurations (http://www.drobsonconsulting.co.uk/cucumber-and-concurrency/). But this is exactly what we want to do when running against BrowserStack.
So this class provides a lookup that is linked to a thread id. This means that when cucumber is creating instances of the Step definitions, the actual configuration of the web driver can be retrieved against a specific thread. In this way we can have multiple threads each creating webdrivers that are consistent for that thread, but different to the other threads.
Modifier and Type | Method and Description |
---|---|
default void |
clearWebDriverForThread(boolean quitDriver)
Clears the web driver assigned to the current thread.
|
void |
clearWebDriverForThread(java.lang.String name,
boolean quitDriver)
Clears the web driver assigned to a thread.
|
default FeatureState |
getDesiredCapabilitiesForThread() |
FeatureState |
getDesiredCapabilitiesForThread(java.lang.String name) |
int |
getNumberCapabilities() |
java.util.List<java.io.File> |
getTempFolders() |
default org.openqa.selenium.WebDriver |
getWebDriverForThread() |
default org.openqa.selenium.WebDriver |
getWebDriverForThread(boolean createIfMissing) |
org.openqa.selenium.WebDriver |
getWebDriverForThread(java.lang.String name,
boolean createIfMissing) |
void |
initialise(java.util.List<org.openqa.selenium.remote.DesiredCapabilities> desiredCapabilities,
java.util.List<UrlMapping> applicationUrls,
java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.String>> datasets,
java.lang.String myReportDirectory,
java.util.List<java.io.File> myTempFolders,
java.util.List<ProxyDetails<?>> myProxies)
Initialise any internal structures with the list of loaded capabilities
|
void |
shutdown()
Cleans up the web drivers
|
void |
shutdown(java.lang.String name)
Cleans up the web drivers for an individual thread
|
void initialise(@NotNull java.util.List<org.openqa.selenium.remote.DesiredCapabilities> desiredCapabilities, @NotNull java.util.List<UrlMapping> applicationUrls, @NotNull java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.String>> datasets, @NotNull java.lang.String myReportDirectory, @NotNull java.util.List<java.io.File> myTempFolders, @NotNull java.util.List<ProxyDetails<?>> myProxies)
desiredCapabilities
- the list of capabilities that were loadedapplicationUrls
- the list of urls assocaited with the application we are testingdatasets
- the datasets that can be used by a test scriptmyReportDirectory
- The directory that holds reports and other test script outputsmyTempFolders
- A list of directories that need to be deleted once the test is completemyProxies
- A list of the proxies that have been configured@NotNull FeatureState getDesiredCapabilitiesForThread(@NotNull java.lang.String name)
name
- The name of the currently executing thread@NotNull default FeatureState getDesiredCapabilitiesForThread()
@NotNull org.openqa.selenium.WebDriver getWebDriverForThread(@NotNull java.lang.String name, boolean createIfMissing)
name
- The name of the currently executing threadcreateIfMissing
- set to true to create a web driver if one doesn't exist@NotNull default org.openqa.selenium.WebDriver getWebDriverForThread(boolean createIfMissing)
createIfMissing
- set to true to create a web driver if one doesn't exist@NotNull default org.openqa.selenium.WebDriver getWebDriverForThread()
void clearWebDriverForThread(@NotNull java.lang.String name, boolean quitDriver)
name
- The name of the threadquitDriver
- true if the driver should quit before it is cleareddefault void clearWebDriverForThread(boolean quitDriver)
quitDriver
- true if the driver should quit before it is clearedint getNumberCapabilities()
java.util.List<java.io.File> getTempFolders()
void shutdown()
void shutdown(@NotNull java.lang.String name)
name
- The name of the thread that should have its associated resources cleaned up