public class WebDriverHelper extends Object
WebDriver instances. Each connect(String, String, String) call
will associate a working instance of WebDriver and will be used until quit() is used or another connect(String, String, String)| Modifier and Type | Class and Description |
|---|---|
static class |
WebDriverHelper.StopTestWithWebDriverException
Exception class so test can be stopped. |
| Constructor and Description |
|---|
WebDriverHelper() |
| Modifier and Type | Method and Description |
|---|---|
ByWebElement |
addCachedElement(org.openqa.selenium.WebElement element) |
void |
clearCacheElements() |
void |
connect(String browser,
String capabilities,
String preferences)
Creates a
WebDriver instance with desired browser and capabilities. |
boolean |
doWhenAvailable(String from,
BiConsumer<org.openqa.selenium.WebDriver,SeleniumLocatorParser.WebElementSelector> callback) |
org.openqa.selenium.WebElement |
getCachedElement(String aId) |
String |
getDryRunWindow() |
long |
getLastActionDurationInSeconds() |
boolean |
getStopTestOnFirstFailure() |
boolean |
getTakeScreenshotOnFailure() |
int |
getTimeoutInSeconds() |
String |
getWhenAvailable(String from,
BiFunction<org.openqa.selenium.WebDriver,SeleniumLocatorParser.WebElementSelector,String> callback)
Core function designed to provide callbacks with selenium context necessary to evaluate commands.
|
boolean |
isBrowserAvailable() |
void |
quit()
Quietly quits the current browser instance
|
void |
setDryRunWindow(String dryRunWindow) |
void |
setStopTestOnFirstFailure(boolean stopTestOnFirstFailure) |
void |
setTakeScreenshotOnFailure(boolean takeScreenshotOnFailure) |
void |
setTimeoutInSeconds(int timeoutInSeconds) |
public void connect(String browser, String capabilities, String preferences) throws ReflectiveOperationException, IOException
WebDriver instance with desired browser and capabilities. Capabilities should follow a key/value formatbrowser - to be initialized. Can be a remote driver URLcapabilities - string. Should follow a key/value formatpreferences - string. Should follow a key/value formatReflectiveOperationException - if remote driver class cannot be instantiatedIOException - if IO error occurs if invalid URL is used when connecting to remote driversWebDriverCapabilitiesHelper.parse(String, String, String)public void quit()
public boolean doWhenAvailable(String from, BiConsumer<org.openqa.selenium.WebDriver,SeleniumLocatorParser.WebElementSelector> callback)
public String getWhenAvailable(String from, BiFunction<org.openqa.selenium.WebDriver,SeleniumLocatorParser.WebElementSelector,String> callback)
SeleniumLocatorParser.parse(String))WebElement to run commmands, or fails for any other reason, the callback will be reinvoked until a positive return happens or
getTimeoutInSeconds() is reachedSeleniumLocatorParser.WebElementSelector.getExpectedValue(), the callback will be reinvoked until the value matches or
getTimeoutInSeconds() is reachedSeleniumLocatorParser.WebElementSelector.getExpectedValue() (or SeleniumLocatorParser.WebElementSelector.getExpectedValue() is empty), the result will be
returnedfrom - selenium selector received by the fixture@param fromcallback - The callback to be invoked with SeleniumLocatorParser.WebElementSelector and WebDriverWebDriverHelper.StopTestWithWebDriverException - if isBrowserAvailable() returns false or if getStopTestOnFirstFailure() is true and any failure occurspublic boolean isBrowserAvailable()
public void setTimeoutInSeconds(int timeoutInSeconds)
timeoutInSeconds - Timeout to wait for elements to be present. Default is 20 secondspublic int getTimeoutInSeconds()
public void setStopTestOnFirstFailure(boolean stopTestOnFirstFailure)
stopTestOnFirstFailure - If true, if any error occurs while running selenium actions, test will be stopped.public boolean getStopTestOnFirstFailure()
public long getLastActionDurationInSeconds()
public boolean getTakeScreenshotOnFailure()
public void setTakeScreenshotOnFailure(boolean takeScreenshotOnFailure)
takeScreenshotOnFailure - If true, will embed exceptions with screenshot data (if available). Default is truepublic String getDryRunWindow()
public void setDryRunWindow(String dryRunWindow)
public void clearCacheElements()
public ByWebElement addCachedElement(org.openqa.selenium.WebElement element)
public org.openqa.selenium.WebElement getCachedElement(String aId)
Copyright © 2018. All rights reserved.