public class Browser extends Object
WebDriver
: by opening a Browser, a WebDriver is instantiated.
It relies on a WebDriverFactory
for instantiating WebDriver
s.
The factory may be injected in the constructor.
See Browser()
for details on the default factory.
A Browser has a type, one of SupportedBrowser
.
The type is not bound to an instance of Browser: it is chosen when opening the browser.
Thus, a Browser instance, during its life, may represent many different types
of browsers (one for each pair of calls to open(SupportedBrowser)
and close()
).
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
logger |
Constructor and Description |
---|
Browser()
Inject the default
WebDriverFactory , which is
WebDriverFactoryProvider.fromConfig |
Browser(WebDriverFactory driverFactory)
Create a Browser and inject the given
WebDriverFactory . |
Modifier and Type | Method and Description |
---|---|
void |
browseBack() |
<T extends LoadablePage> |
browseTo(Class<T> loadablePageClass)
Browse to the given
LoadablePage , and return its instance. |
void |
browseTo(String relativeUrl) |
void |
close()
Close the browser by quitting the underlying
WebDriver . |
SupportedBrowser |
getType() |
org.openqa.selenium.WebDriver |
getWebDriver() |
boolean |
isOpen() |
void |
open(SupportedBrowser browserType)
Open a browser according to the given parameter,
by instantiating a
WebDriver . |
public Browser()
WebDriverFactory
, which is
WebDriverFactoryProvider.fromConfig
public Browser(WebDriverFactory driverFactory)
WebDriverFactory
.driverFactory
- public void open(SupportedBrowser browserType)
WebDriver
.
Do nothing if this browser was already open.public void close()
WebDriver
.
Do nothing if this browser was not open.WebDriver.quit()
public void browseTo(String relativeUrl)
PageHelper.Navigation#browseTo(String, WebDriver)
public <T extends LoadablePage> T browseTo(Class<T> loadablePageClass)
LoadablePage
, and return its instance.LoadablePage
LoadablePage.load(Class, WebDriver)
public void browseBack()
PageHelper.Navigation#browseBack(WebDriver)
public boolean isOpen()
public org.openqa.selenium.WebDriver getWebDriver()
public SupportedBrowser getType()
Copyright © 2015. All rights reserved.