|
| 1 | +[Home](../README.md) |
| 2 | + |
| 3 | +# Browser Factories |
| 4 | + |
| 5 | +A `BrowserFactory` creates an abstraction over the `Browser` initialization based on project-global settings. |
| 6 | +They are intended to allow easy browser initialization and encapsulation of the underlying configuration / initialization |
| 7 | +processes. Most projects implement their own factories according to their specific environment. |
| 8 | +In case you just want to get started, we provide factories for the most common browsers: |
| 9 | + |
| 10 | +- `ChromeFactory` |
| 11 | +- `FirefoxFactory` |
| 12 | +- `MarionetteFactory` (new Firefox driver) |
| 13 | +- `InternetExplorerFactory` |
| 14 | + |
| 15 | +All of these are provided by the `webtester-core` module, but need you to provide the corresponding Selenium `WebDriver` dependencies yourself. |
| 16 | + |
| 17 | +## ProxyConfiguration |
| 18 | + |
| 19 | +In order to configure a proxy you can either configure it manually when initializing the `WebDriver` or |
| 20 | +you can implement a `ProxyConfiguration` and provide it to the `BrowserFactory` before creating a `Browser` instance. |
| 21 | + |
| 22 | +```java |
| 23 | +ProxyConfiguration pc = createProxyConfiguration(); |
| 24 | +Browser browser = new FirefoxFactory().withProxyConfiguration(pc).createBrowser(); |
| 25 | +``` |
| 26 | + |
| 27 | + |
| 28 | +## ChromeFactory |
| 29 | + |
| 30 | +This `BrowserFactory` uses the `selenium-chrome-driver` to create new Chrome `Browser` instances. |
| 31 | + |
| 32 | +### Default Driver Configuration |
| 33 | +In order to optimize testing the following properties are set when creating a `WebDriver` using the `ChromeFactory`: |
| 34 | + |
| 35 | +- Native events are disabled -> Selenium does not simulate human typing. |
| 36 | +- Untrusted certificates are always accepted. |
| 37 | + |
| 38 | +### Additional Service Executable |
| 39 | +The 'ChromeDriver' needs an additional executable to communicate with a Chrome browser. |
| 40 | +It can be downloaded [here](https://sites.google.com/a/chromium.org/chromedriver/downloads). |
| 41 | + |
| 42 | +The path to the executable must be declared as a system or environment property named: `webdriver.chrome.driver` |
| 43 | + |
| 44 | +**Additional Information:** |
| 45 | +- https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver |
| 46 | + |
| 47 | + |
| 48 | +## FirefoxFactory and MarionetteFactory |
| 49 | + |
| 50 | +These `BrowserFactory` implementations use the `selenium-firefox-driver` to create new Firefox `Browser` instances. |
| 51 | +To drive Firefox browsers up to version 46, the `FirefoxFactory` *can* be used. |
| 52 | +In order to drive newer versions (47++), the `MarionetteFactory` *must* be used. |
| 53 | +The only real difference between these two factories is the activation of the `marionnette` capability. |
| 54 | + |
| 55 | +### Default Driver Configuration |
| 56 | +In order to optimize testing the following properties are set when creating a `WebDriver` using the `FirefoxFactory`: |
| 57 | + |
| 58 | +- Native events are disabled -> Selenium does not simulate human typing. |
| 59 | +- Untrusted certificates are always accepted. |
| 60 | + |
| 61 | +### Additional Service Executable |
| 62 | + |
| 63 | +Using the Marionette-activated `WebDriver` will force you to also specify the location of a `GeckoDriver` instance. |
| 64 | +This is basically a proxy between Selenium and the actual Firefox (like with the `ChromeDriver`). |
| 65 | +it can be downloaded [here](https://github.com/mozilla/geckodriver/releases) |
| 66 | + |
| 67 | +The path to the executable must be declared as a system or environment property named: `webdriver.gecko.driver` |
| 68 | + |
| 69 | +**Additional Information:** |
| 70 | +- https://github.com/SeleniumHQ/selenium/wiki/FirefoxDriver |
| 71 | +- https://github.com/mozilla/geckodriver |
| 72 | +- https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette |
| 73 | + |
| 74 | + |
| 75 | +## InternetExplorerFactory |
| 76 | + |
| 77 | +This `BrowserFactory` uses the `selenium-ie-driver` to create new Internet Explorer `Browser` instances. |
| 78 | + |
| 79 | +### Default Driver Configuration |
| 80 | +In order to optimize testing the following properties are set when creating a `WebDriver` using the `InternetExplorerFactory`: |
| 81 | + |
| 82 | +- Native events are disabled -> Selenium does not simulate human typing. |
| 83 | +- Untrusted certificates are always accepted. |
| 84 | + |
| 85 | +### Additional Service Executable |
| 86 | +The `InternetExplorerDriver` needs an additional executable to communicate with a IE browser. |
| 87 | +It can be downloaded [here](http://selenium-release.storage.googleapis.com/index.html). |
| 88 | + |
| 89 | +The path to the executable must be declared as a system or environment property named: `webdriver.ie.driver` |
| 90 | + |
| 91 | +**Additional Information:** |
| 92 | +- https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver |
| 93 | + |
| 94 | +# Linked Documentation |
| 95 | + |
| 96 | +- [Browser](browser.md) |
| 97 | + |
0 commit comments