public final class WebDriverWrapper extends Object
Modifier and Type | Class and Description |
---|---|
static class |
WebDriverWrapper.Browser
Enumerates browser options for Browserstack.
|
Modifier and Type | Field and Description |
---|---|
private static WebDriverWrapper |
activeWrapper
The previously instantiated wrapper, to prevent reinstatiation without
quit.
|
private static String |
BROWSER_CAPABILITY_KEY
Browserstack capability key.
|
private static String |
BROWSER_DEBUG_FLAG_DESIRED_CAPABILITY_KEY_VALUE
Browserstack/Selenium 'Desired Capabilities' debug flag capaibilty key.
|
private static WebDriverWrapper.Browser |
BROWSER_SELECTION
Browserstack/Selenium browser 'Desired Capabilities' capability key.
|
private static String |
BROWSERSTACK_BUILD_NAME_CAPABILITY_KEY
Browserstack/Selenium build name capability.
|
private static String |
BROWSERSTACK_BUILD_NAME_DESIRED_CAPABILITY_KEY_VALUE
Browserstack/Selenium 'Desired Capabilities' build name capability key.
|
private static String |
BROWSERSTACK_DEBUG_CAPABILITY_KEY
Browserstack/Selenium debug flag capability.
|
private String |
buildName
Build name for Browserstack UI organization.
|
private String |
elementTimeout
Element timeout in seconds.
|
private static String |
REINSTANTIATION_EXCEPTION_CODE
Message if wrapper is re-instantiated with out quitting previous.
|
private String |
systemUrl
System URL.
|
private org.openqa.selenium.WebDriver |
webDriver
Selenium Webdriver.
|
Modifier | Constructor and Description |
---|---|
private |
WebDriverWrapper(org.openqa.selenium.WebDriver webDriverParam,
String buildNameParam)
Constructs wrapper, stores webDriver reference.
|
Modifier and Type | Method and Description |
---|---|
org.openqa.selenium.WebElement |
findElement(org.openqa.selenium.By byParam)
Returns an instance of a Selenium html elmement.
|
List<org.openqa.selenium.WebElement> |
findElements(org.openqa.selenium.By byParam)
Returns list of web page elements, using Selenium.
|
void |
get(String targetUrlString)
Sends remote browser to specified URL.
|
String |
getBodyText()
Retrieve body element from target.
|
static String |
getBrowserCapabilityKey()
Browserstack capability key.
|
static String |
getBrowserDebugFlagDesiredCapabilityKeyValue()
Browserstack/Selenium 'Desired Capabilities' debug flag capaibilty key.
|
static WebDriverWrapper.Browser |
getBrowserSelection()
Browserstack/Selenium browser 'Desired Capabilities' capability key.
|
static String |
getBrowserstackBuildNameCapabilityKey()
Browserstack/Selenium build name capability.
|
static String |
getBrowserstackBuildNameDesiredCapabilityKeyValue()
Browserstack/Selenium 'Desired Capabilities' build name capability key.
|
static String |
getBrowserstackDebugCapabilityKey()
Browserstack/Selenium debug flag capability.
|
String |
getBuildName()
Returns buildname.
|
static org.openqa.selenium.remote.DesiredCapabilities |
getDesiredCapabilities(String browserKeyParam,
String debugKeyParam,
String buildNameKeyParam,
WebDriverWrapper.Browser browserValueParam,
String debugValueParam,
String buildNameValueParam)
Creates webDriver DesiredCapabilities object.
|
String |
getPageSource()
Retrieve page source from target.
|
private static WebDriverWrapper |
getPreviousWrapper()
Retrieves previously instantiated wrapper that is still active.
|
private org.openqa.selenium.WebDriver |
getWebDriver()
Provides direct access to web driver.
|
String |
getWebDriverToString()
Provides access to active WebDriver toString() method.
|
private boolean |
isBuildName(String buildNameParam)
Returns true if buildname matches.
|
boolean |
isInactive()
Checks if *this* wrapper is not active due to quit().
|
static boolean |
isInitialized()
Is wrapper initialized?
|
static void |
log(String logEntryParam)
Logs wrapper activity.
|
private static org.openqa.selenium.WebDriver |
newWebDriver(String buildNameParam)
Initializes webdriver.
|
static WebDriverWrapper |
newWebDriverWrapper()
Returns previous wrapper unless previous has been de-initialized.
|
static WebDriverWrapper |
newWebDriverWrapper(String buildNameParam)
Recycles previous wrapper if possible;
if it matches existing build name.
|
static WebDriverWrapper |
newWebDriverWrapper(String buildNameParam,
org.openqa.selenium.WebDriver webDriverParam)
Uses previous wrapper if possible;
matches build name.
|
void |
quit()
Quits webdriver and designates this wrapper as inactive.
|
static void |
setActiveWrapper(WebDriverWrapper wrapperParam)
Stores latest instantiated wrapper.
|
String |
toString()
Returns object state without any secrets.
|
void |
waitSeconds(long secondsParam)
Waits so webdriver can load all elements.
|
private static final String REINSTANTIATION_EXCEPTION_CODE
private static final String BROWSER_CAPABILITY_KEY
private static final String BROWSERSTACK_DEBUG_CAPABILITY_KEY
private static final String BROWSERSTACK_BUILD_NAME_CAPABILITY_KEY
private static final WebDriverWrapper.Browser BROWSER_SELECTION
private static final String BROWSER_DEBUG_FLAG_DESIRED_CAPABILITY_KEY_VALUE
private static final String BROWSERSTACK_BUILD_NAME_DESIRED_CAPABILITY_KEY_VALUE
private static WebDriverWrapper activeWrapper
private String buildName
private org.openqa.selenium.WebDriver webDriver
private String systemUrl
private String elementTimeout
private WebDriverWrapper(org.openqa.selenium.WebDriver webDriverParam, String buildNameParam)
webDriverParam
- web driver to wrapbuildNameParam
- name of build to be tracked on Browserstackpublic static boolean isInitialized()
public static String getBrowserCapabilityKey()
public static String getBrowserstackDebugCapabilityKey()
public static String getBrowserstackBuildNameCapabilityKey()
public static WebDriverWrapper.Browser getBrowserSelection()
public static String getBrowserDebugFlagDesiredCapabilityKeyValue()
public static String getBrowserstackBuildNameDesiredCapabilityKeyValue()
public static WebDriverWrapper newWebDriverWrapper(String buildNameParam)
buildNameParam
- Name of build to use to organize tests on Browserstackpublic static WebDriverWrapper newWebDriverWrapper(String buildNameParam, org.openqa.selenium.WebDriver webDriverParam)
webDriverParam
- driver to wrapbuildNameParam
- Name of build to use to organize tests on Browserstackpublic static WebDriverWrapper newWebDriverWrapper()
public static org.openqa.selenium.remote.DesiredCapabilities getDesiredCapabilities(String browserKeyParam, String debugKeyParam, String buildNameKeyParam, WebDriverWrapper.Browser browserValueParam, String debugValueParam, String buildNameValueParam)
browserKeyParam
- label for browser requested fielddebugKeyParam
- label for debug key fieldbuildNameKeyParam
- label for build name fieldbrowserValueParam
- value for browser requesteddebugValueParam
- value for debug valuebuildNameValueParam
- value for build namepublic static void log(String logEntryParam)
logEntryParam
- text to logprivate static WebDriverWrapper getPreviousWrapper()
public static void setActiveWrapper(WebDriverWrapper wrapperParam)
wrapperParam
- reference to wrapper, to be storedprivate static org.openqa.selenium.WebDriver newWebDriver(String buildNameParam)
buildNameParam
- build name to useprivate boolean isBuildName(String buildNameParam)
buildNameParam
- build name to checkpublic String getBuildName()
public void waitSeconds(long secondsParam)
secondsParam
- Time (in seconds) to wait before timing out the element
search.public String getPageSource()
public String getBodyText()
public boolean isInactive()
public String toString()
public void get(String targetUrlString)
targetUrlString
- URL to loadpublic org.openqa.selenium.WebElement findElement(org.openqa.selenium.By byParam)
byParam
- Selenium element locator.public List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By byParam)
byParam
- Selenium element locator.public void quit()
public String getWebDriverToString()
private org.openqa.selenium.WebDriver getWebDriver()
IllegalStateException
- if this instance has not been initialized with a driver.Copyright © 2018. All rights reserved.