/** * Creates a new ChromeDriver instance with the specified options. * * @param options The options to use. * @see #ChromeDriver(ChromeDriverService, ChromeOptions) */ public ChromeDriver(ChromeOptions options) { this(ChromeDriverService.createDefaultService(), options); }
private static void initializeSeleniumDriver() throws IOException { if (null == DRIVERSERVICE) { final String theChromeDriverBinary = System.getenv("CHROMEDRIVER_BINARY"); if (null == theChromeDriverBinary || theChromeDriverBinary.isEmpty()) { throw new RuntimeException("No chromedriver binary found! Please set CHROMEDRIVER_BINARY environment variable!"); } ChromeDriverService.Builder theDriverService = new ChromeDriverService.Builder(); theDriverService = theDriverService.withVerbose(false); theDriverService = theDriverService.usingDriverExecutable(new File(theChromeDriverBinary)); DRIVERSERVICE = theDriverService.build(); DRIVERSERVICE.start(); Runtime.getRuntime().addShutdownHook(new Thread(() -> DRIVERSERVICE.stop())); } }
public DebateFetcher(String chromeDriverFile) throws IOException { service = new ChromeDriverService.Builder() .usingDriverExecutable( new File(chromeDriverFile)) .usingAnyFreePort() .withEnvironment(ImmutableMap.of("DISPLAY", ":20")).build(); service.start(); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); driver = new RemoteWebDriver(service.getUrl(), capabilities); }
ChromeDriverService chromeDriverService = new ChromeDriverService.Builder() .usingDriverExecutable(new File(ChromeUtils.getChromeDriverPath())) .usingAnyFreePort() .withEnvironment(ImmutableMap.of("DISPLAY",":1024")) .build(); try { chromeDriverService.start(); webDriver = new ChromeDriver(chromeDriverService, caps); } ....
public void finishFetching() { driver.quit(); service.stop(); }
private WebDriver newDriverForTest() { final ChromeOptions theOptions = new ChromeOptions().setHeadless(true); theOptions.addArguments("--js-flags=experimental-wasm-eh"); theOptions.addArguments("--enable-experimental-wasm-eh"); final LoggingPreferences theLoggingPreferences = new LoggingPreferences(); theLoggingPreferences.enable(LogType.BROWSER, Level.ALL); theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences); final DesiredCapabilities theCapabilities = DesiredCapabilities.chrome(); theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions); return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities); }
@Override protected ChromeDriverService createDriverService( File exe, int port, ImmutableList<String> args, ImmutableMap<String, String> environment) { try { return new ChromeDriverService(exe, port, args, environment); } catch (IOException e) { throw new WebDriverException(e); } } }
private static void initializeSeleniumDriver() throws IOException { if (null == DRIVERSERVICE) { final String theChromeDriverBinary = System.getenv("CHROMEDRIVER_BINARY"); if (null == theChromeDriverBinary || theChromeDriverBinary.isEmpty()) { throw new RuntimeException("No chromedriver binary found! Please set CHROMEDRIVER_BINARY environment variable!"); } ChromeDriverService.Builder theDriverService = new ChromeDriverService.Builder(); theDriverService = theDriverService.withVerbose(false); theDriverService = theDriverService.usingDriverExecutable(new File(theChromeDriverBinary)); DRIVERSERVICE = theDriverService.build(); DRIVERSERVICE.start(); Runtime.getRuntime().addShutdownHook(new Thread(() -> DRIVERSERVICE.stop())); } }
ChromeDriverService cds = ChromeDriverService.createDefaultService(); try { cds.start(); } catch (IOException e) { e.printStackTrace();
private WebDriver newDriverForTest() { final ChromeOptions theOptions = new ChromeOptions().setHeadless(true); theOptions.addArguments("--js-flags=experimental-wasm-eh"); theOptions.addArguments("--enable-experimental-wasm-eh"); final LoggingPreferences theLoggingPreferences = new LoggingPreferences(); theLoggingPreferences.enable(LogType.BROWSER, Level.ALL); theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences); final DesiredCapabilities theCapabilities = DesiredCapabilities.chrome(); theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions); return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities); }
public WebDriver getDriver() { try { File file = new File(Config.chrome_webdriver_location); ChromeDriverService service = new ChromeDriverService.Builder() .usingDriverExecutable(file) .usingAnyFreePort().build(); service.start(); WebDriver instance = new ChromeDriver(service, DesiredCapabilities.chrome()); log.info("Found webdriver instance : " + instance); return instance; } catch (IOException e) { e.printStackTrace(); } log.info("Returning back null web driver"); return new NullWebDriver(); }
@Override public ChromeDriverService getDriverService() { return ChromeDriverService.createDefaultService(); }
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; }
/** * Get the ChromeDriverService to use. Exists to allow subclasses to override. * * @return the default chrome service. */ public ChromeDriverService getChromeDriverService() { return ChromeDriverService.createDefaultService(); }
@Override public boolean isAvailable() { try { ChromeDriverService.createDefaultService(); return true; } catch (IllegalStateException | WebDriverException e) { return false; } }
public ChromeDriverEx(Capabilities capabilities) { this(ChromeDriverService.createDefaultService(), capabilities); }
/** * Creates a new ChromeDriver instance. The {@code capabilities} will be passed to the * ChromeDriver service. * * @param capabilities The capabilities required from the ChromeDriver. * @see #ChromeDriver(ChromeDriverService, Capabilities) * @deprecated Use {@link ChromeDriver(ChromeOptions)} instead. */ @Deprecated public ChromeDriver(Capabilities capabilities) { this(ChromeDriverService.createDefaultService(), capabilities); }