Java Code Examples for org.openqa.selenium.chrome.ChromeDriverService#start()

The following examples show how to use org.openqa.selenium.chrome.ChromeDriverService#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestChromeDriver.java    From selenium with Apache License 2.0 6 votes vote down vote up
private static ChromeDriverService getService() {
  try {
    Path logFile = Files.createTempFile("chromedriver", ".log");
    ChromeDriverService service = new ChromeDriverService.Builder()
        .withLogLevel(ChromeDriverLogLevel.ALL)
        .withLogFile(logFile.toFile())
        .build();
    LOG.info("chromedriver will log to " + logFile);
    LOG.info("chromedriver will use log level " + ChromeDriverLogLevel.ALL.toString().toUpperCase());
    service.start();
    // Fugly.
    Runtime.getRuntime().addShutdownHook(new Thread(service::stop));
    return service;
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example 2
Source File: ChromeDriverConfig.java    From jmeter-plugins-webdriver with Apache License 2.0 5 votes vote down vote up
private ChromeDriverService getThreadService() {
    ChromeDriverService service = services.get(currentThreadName());
    if (service != null) {
        return service;
    }
    try {
        service = new ChromeDriverService.Builder().usingDriverExecutable(new File(getChromeDriverPath())).build();
        service.start();
        services.put(currentThreadName(), service);
    } catch (IOException e) {
        LOGGER.error("Failed to start chrome service");
        service = null;
    }
    return service;
}