A Browser provides a streamlined and context centric API for the interaction with a web browser.
A BrowserBuilder provides the framework for initializing Browser instances and setting custom service implementations.
Customizable services are:
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.
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 WebDriverBrowser class implements Browser and is used to wrap a Selenium WebDriver.
Instances can be created by using the WebDriverBrowser's factory methods:
WebDriverBrowser.forWebDriver(webDriver).build();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.
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();