info.novatec.testit.webtester.browser.factories.ChromeFactory Maven / Gradle / Ivy
package info.novatec.testit.webtester.browser.factories;
import org.openqa.selenium.chrome.ChromeDriver;
import info.novatec.testit.webtester.browser.Browser;
import info.novatec.testit.webtester.config.Configuration;
import org.openqa.selenium.chrome.ChromeOptions;
/**
* Factory class for creating Chrome {@link Browser} instances.
* Needs the {@code webdriver.chrome.driver} system property pointing to the driver proxy server executable.
*
* The following capabilities are set by default:
*
* - Native Events are disabled
* - Unsigned certificates are accepted
*
* Additional information on using the {@link ChromeDriver}:
*
* https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver
*
* @see Browser
* @see ChromeDriver
* @since 2.1
*/
public class ChromeFactory extends BaseBrowserFactory {
private static final String DRIVER_LOCATION = "webdriver.chrome.driver";
public ChromeFactory() {
super((capabilities) -> {
ChromeOptions chromeOptions = new ChromeOptions().merge(capabilities);
return new ChromeDriver(chromeOptions);
});
}
@Override
protected void postProcessConfiguration(Configuration configuration) {
configuration.getStringProperty(DRIVER_LOCATION).ifPresent(driverLocation -> {
System.setProperty(DRIVER_LOCATION, driverLocation);
});
}
}