Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Latest commit

 

History

History
79 lines (60 loc) · 2.9 KB

File metadata and controls

79 lines (60 loc) · 2.9 KB

Home

Browser

Interfaces

Browser

A Browser provides a streamlined and context centric API for the interaction with a web browser.

BrowserBuilder

A BrowserBuilder provides the framework for initializing Browser instances and setting custom service implementations. Customizable services are:

BrowserFactory

A BrowserFactory creates an abstraction over the Browser initialisation based on project-global settings. They are intended to allow easy browser initialization and encapsulation of the underlying configuration / initialization processes.

Provided default BrowserFactory implementations:

Each of them comes in their own support module. The Firefox's factory implementation is trimmed for optimal performance.

ProxyConfiguration

In order to configure a proxy you can either configure it manually when initializing the WebDriver or you can implement a ProxyConfiguration and provide it to the BrowserFactory before creating a Browser instance.

ProxyConfiguration pc = createProxyConfiguration();
Browser browser = new FirefoxFactory().withProxyConfiguration(pc).createBrowser();

The WebDriver Browser

The WebDriverBrowser class implements Browser and is used to wrap a Selenium WebDriver. Instances can be created by using the WebDriverBrowser's factory methods:

  1. WebDriverBrowser.forWebDriver(webDriver).build();
  2. WebDriverBrowser.buildForWebDriver(webDriver);

Both of these are equal. The first method can be used to customize same aspects of the browser before it is build.

Examples

Initialization of a new WebDriverBrowser instance:

WebDriver webDriver = createWebDriver();
Browser browser = WebDriverBrowser.buildForWebDriver(webDriver);
Browser browser = WebDriverBrowser.forWebDriver(webDriver).build();
Browser browser = new WebDriverBrowserBuilder(webDriver).build();

Initialization of a new WebDriverBrowser instance with custom service implementations:

Configuration config = createConfiguration();
PageObjectFactory factory = createFactory();

Browser browser = WebDriverBrowser.forWebDriver(webDriver)
                        .withConfiguration(config)
                        .withFactory(factory)
                        .build();

Browser browser = new WebDriverBrowserBuilder(webDriver)
                        .withConfiguration(config)
                        .withFactory(factory)
                        .build();

Linked Documentation