Example usage for org.openqa.selenium.chrome ChromeDriverService CHROME_DRIVER_LOG_PROPERTY

List of usage examples for org.openqa.selenium.chrome ChromeDriverService CHROME_DRIVER_LOG_PROPERTY

Introduction

In this page you can find the example usage for org.openqa.selenium.chrome ChromeDriverService CHROME_DRIVER_LOG_PROPERTY.

Prototype

String CHROME_DRIVER_LOG_PROPERTY

To view the source code for org.openqa.selenium.chrome ChromeDriverService CHROME_DRIVER_LOG_PROPERTY.

Click Source Link

Document

System property that defines the location of the log that will be written by the #createDefaultService() default service .

Usage

From source file:org.atteo.moonshine.webdriver.browsers.ChromeBrowser.java

License:Apache License

public ChromeBrowser() {
    System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, "target/chromedriver.log");
    try {/* www. j a  v  a2 s . co m*/
        service = ChromeDriverService.createDefaultService();
        service.start();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.zanata.page.WebDriverFactory.java

License:Open Source License

private EventFiringWebDriver configureChromeDriver() {
    System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY,
            PropertiesHolder.getProperty("webdriver.log"));
    driverService = ChromeDriverService.createDefaultService();
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability("chrome.binary",
            PropertiesHolder.properties.getProperty("webdriver.chrome.bin"));

    ChromeOptions options = new ChromeOptions();
    URL url = Thread.currentThread().getContextClassLoader()
            .getResource("zanata-testing-extension/chrome/manifest.json");
    assert url != null : "can't find extension (check testResource config in pom.xml)";
    File file = new File(url.getPath()).getParentFile();
    options.addArguments("load-extension=" + file.getAbsolutePath());
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);

    enableLogging(capabilities);/*from   w w w . j a  v a2 s. c  om*/

    // start the proxy
    BrowserMobProxy proxy = new BrowserMobProxyServer();
    proxy.start(0);

    proxy.addFirstHttpFilterFactory(
            new ResponseFilterAdapter.FilterSource((response, contents, messageInfo) -> {
                // TODO fail test if response >= 500?
                if (response.getStatus().code() >= 400) {
                    log.warn("Response {} for URI {}", response.getStatus(),
                            messageInfo.getOriginalRequest().getUri());
                } else {
                    log.info("Response {} for URI {}", response.getStatus(),
                            messageInfo.getOriginalRequest().getUri());
                }
            }, 0));
    Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
    capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
    try {
        driverService.start();
    } catch (IOException e) {
        throw new RuntimeException("fail to start chrome driver service");
    }
    return new EventFiringWebDriver(
            new Augmenter().augment(new RemoteWebDriver(driverService.getUrl(), capabilities)));
}