Class DecoratedDriver
- java.lang.Object
-
- co.verisoft.fw.selenium.drivers.DecoratedDriver
-
- All Implemented Interfaces:
org.openqa.selenium.HasCapabilities,org.openqa.selenium.JavascriptExecutor,org.openqa.selenium.SearchContext,org.openqa.selenium.TakesScreenshot,org.openqa.selenium.WebDriver,org.openqa.selenium.WrapsDriver
- Direct Known Subclasses:
DecoratedMobileDriver
public class DecoratedDriver extends Object implements org.openqa.selenium.WebDriver, org.openqa.selenium.JavascriptExecutor, org.openqa.selenium.HasCapabilities, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.WrapsDriver
VeriSoft driver. A top level object which handles all types of WebDriver interfaces -
1. Local and Remote
2. All Apppium and Selenium based drivers (Web and mobile are currently supported)
VeriSoft driver is a concrete class which implements a variety of interfaces (which makes it easier not having to perform castings on many operations).
I supports local creation of local WebDriver objects using WebDriverManager package (see more about WebDriverManager at WebDriverManager Github Repository )
It also supports creation of remote WebDriver objects using the built-in Selenium mechanism. VeriSoftDriver follows the RemoteWebDriver.java architecture, and actually stores an instance of RemoteWebDriver in it.
VerisoftDriver implements the WebDriver behavior, and in addition, it also adds some functionality. The main additional functionalities which are currently supported:
1. Async operations. See async operation in the "See Also" section
2. Extended logging
3. All available events included within the Selenium framework are registered. See events in the "See Also" section
4. WebDriver is wrapped with EventFiringDecorator. See in the "See Also" section
The driver is instanciated by specifying the relevant DesiredCapabilities, and if the driver is a remote driver, specifying remote url. All of VeriSoft's ctors expectes at least a DesiredCapabilities object.
All other inner WebDriver class are also implemented as delegate classes.
TODO Add support to client-server drives e.g WinAppDriver and Winium TODO Add additional drivers support such as dockers (see Selenium-Jupiter for a list of supported drivers) TODO Find ways to add unit tests to this class (it is heavily dependened on OS, external SW etc.). Maybe dockers?
Example 1 - Creating a local VerisoftDriver with firefox as driver:
DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("browserName", "firefox"); WebDriver driver = new VerisoftDriver(capabilities); driver.get("http://www.google.com"); String title = driver.getTitle(); if (title == "Google") System.out.println("We are in Google homepage"); driver.close();
Example 2 - Creating a remote VerisoftDriver with safari as driver:
DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("browserName", "safari"); WebDriver driver = new VerisoftDriver("http://remote-url-address:port", capabilities); driver.get("http://www.google.com"); String title = driver.getTitle(); if (title == "Google") System.out.println("We are in Google homepage"); driver.close();- Since:
- 1.9.6
- Author:
- Nir Gallner @ www.VeriSoft.co
- See Also:
RemoteWebDriver,AsyncTask
-
-
Field Summary
Fields Modifier and Type Field Description protected org.openqa.selenium.WebDriverdecoratedDriver
-
Constructor Summary
Constructors Constructor Description DecoratedDriver(@Nullable org.openqa.selenium.Capabilities capabilities)C-tor for local drivers onlyDecoratedDriver(URL remoteAddress, org.openqa.selenium.Capabilities capabilities)C-tor for local and remote drivers
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voiddecorateDriver(@NotNull List<org.openqa.selenium.support.events.WebDriverListener> listeners)voiddecorateDriver(Class clazz)ObjectexecuteAsyncScript(String script, Object... args)ObjectexecuteScript(String script, Object... args)org.openqa.selenium.WebElementfindElement(org.openqa.selenium.By by)List<org.openqa.selenium.WebElement>findElements(org.openqa.selenium.By by)voidget(String url)org.openqa.selenium.CapabilitiesgetCapabilities()StringgetCurrentUrl()StringgetPageSource()<X> XgetScreenshotAs(org.openqa.selenium.OutputType<X> target)StringgetTitle()StringgetWindowHandle()Set<String>getWindowHandles()org.openqa.selenium.WebDrivergetWrappedDriver()org.openqa.selenium.WebDriver.Optionsmanage()org.openqa.selenium.WebDriver.Navigationnavigate()voidquit()org.openqa.selenium.WebDriver.TargetLocatorswitchTo()
-
-
-
Constructor Detail
-
DecoratedDriver
public DecoratedDriver(@Nullable @Nullable org.openqa.selenium.Capabilities capabilities)C-tor for local drivers only- Parameters:
capabilities- cpabilities object
-
DecoratedDriver
public DecoratedDriver(URL remoteAddress, org.openqa.selenium.Capabilities capabilities)
C-tor for local and remote drivers- Parameters:
remoteAddress- address of the remote Selenium servercapabilities- capabilities object
-
-
Method Detail
-
decorateDriver
public void decorateDriver(@NotNull @NotNull List<org.openqa.selenium.support.events.WebDriverListener> listeners)
-
decorateDriver
public void decorateDriver(Class clazz)
-
get
public void get(String url)
- Specified by:
getin interfaceorg.openqa.selenium.WebDriver
-
getCurrentUrl
public String getCurrentUrl()
- Specified by:
getCurrentUrlin interfaceorg.openqa.selenium.WebDriver
-
getTitle
public String getTitle()
- Specified by:
getTitlein interfaceorg.openqa.selenium.WebDriver
-
findElements
public List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
- Specified by:
findElementsin interfaceorg.openqa.selenium.SearchContext- Specified by:
findElementsin interfaceorg.openqa.selenium.WebDriver
-
findElement
public org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
- Specified by:
findElementin interfaceorg.openqa.selenium.SearchContext- Specified by:
findElementin interfaceorg.openqa.selenium.WebDriver
-
getPageSource
public String getPageSource()
- Specified by:
getPageSourcein interfaceorg.openqa.selenium.WebDriver
-
close
public void close()
- Specified by:
closein interfaceorg.openqa.selenium.WebDriver
-
quit
public void quit()
- Specified by:
quitin interfaceorg.openqa.selenium.WebDriver
-
getWindowHandles
public Set<String> getWindowHandles()
- Specified by:
getWindowHandlesin interfaceorg.openqa.selenium.WebDriver
-
getWindowHandle
public String getWindowHandle()
- Specified by:
getWindowHandlein interfaceorg.openqa.selenium.WebDriver
-
switchTo
public org.openqa.selenium.WebDriver.TargetLocator switchTo()
- Specified by:
switchToin interfaceorg.openqa.selenium.WebDriver
-
navigate
public org.openqa.selenium.WebDriver.Navigation navigate()
- Specified by:
navigatein interfaceorg.openqa.selenium.WebDriver
-
manage
public org.openqa.selenium.WebDriver.Options manage()
- Specified by:
managein interfaceorg.openqa.selenium.WebDriver
-
getCapabilities
public org.openqa.selenium.Capabilities getCapabilities()
- Specified by:
getCapabilitiesin interfaceorg.openqa.selenium.HasCapabilities
-
executeScript
public Object executeScript(String script, Object... args)
- Specified by:
executeScriptin interfaceorg.openqa.selenium.JavascriptExecutor
-
executeAsyncScript
public Object executeAsyncScript(String script, Object... args)
- Specified by:
executeAsyncScriptin interfaceorg.openqa.selenium.JavascriptExecutor
-
getScreenshotAs
public <X> X getScreenshotAs(org.openqa.selenium.OutputType<X> target) throws org.openqa.selenium.WebDriverException- Specified by:
getScreenshotAsin interfaceorg.openqa.selenium.TakesScreenshot- Throws:
org.openqa.selenium.WebDriverException
-
getWrappedDriver
public org.openqa.selenium.WebDriver getWrappedDriver()
- Specified by:
getWrappedDriverin interfaceorg.openqa.selenium.WrapsDriver
-
-