private InternetExplorerDriverService getThreadService() { InternetExplorerDriverService service = services.get(currentThreadName()); if (service != null) { return service; } try { service = new InternetExplorerDriverService.Builder().usingDriverExecutable(new File(getInternetExplorerDriverPath())).build(); service.start(); services.put(currentThreadName(), service); } catch (IOException e) { LOGGER.error("Failed to start chrome service"); service = null; } return service; } }
@Override protected ImmutableList<String> createArgs() { if (getLogFile() == null) { String logFilePath = System.getProperty(IE_DRIVER_LOGFILE_PROPERTY); if (logFilePath != null) { withLogFile(new File(logFilePath)); argsBuilder.add(String.format("--port=%d", getPort())); if (getLogFile() != null) { argsBuilder.add(String.format("--log-file=\"%s\"", getLogFile().getAbsolutePath()));
private InternetExplorerDriverService setupService(Capabilities caps, int port) { InternetExplorerDriverService.Builder builder = new InternetExplorerDriverService.Builder(); builder.usingPort(port); String value = (String) caps.getCapability(LOG_FILE); if (value != null) { builder.withLogFile(new File(value)); String value = (String) caps.getCapability(LOG_LEVEL); if (value != null) { builder.withLogLevel(InternetExplorerDriverLogLevel.valueOf(value)); String value = (String) caps.getCapability(HOST); if (value != null) { builder.withHost(value); String value = (String) caps.getCapability(EXTRACT_PATH); if (value != null) { builder.withExtractPath(new File(value)); Boolean value = (Boolean) caps.getCapability(SILENT); if (value != null) { builder.withSilent(value); return builder.build();
InternetExplorerDriverService.Builder ieDriverService = new InternetExplorerDriverService.Builder().withSilent(true); WebDriver driver = new InternetExplorerDriver(ieDriverService.build());
public static InternetExplorerDriver createIeDriver(@Nullable String browserPath, @Nullable BrowserConfig config) { if (noBrowserPath(browserPath) && noServicePath(config)) { return createDefaultDriver(); } else { final InternetExplorerDriverService service = setBrowserExecutablePath(browserPath, setServiceExecutablePath(config, new InternetExplorerDriverService.Builder())) .usingAnyFreePort() .build(); return new InternetExplorerDriver(service); } }
@Override public DriverService createDriverService() { Builder builder = new InternetExplorerDriverService.Builder(); if (port != null) builder.usingPort(port); if (driverExecutable != null) builder.usingDriverExecutable(driverExecutable); if (environment != null) builder.withEnvironment(environment); if (logFile != null) builder.withLogFile(logFile); if (logLevel != null) builder.withLogLevel(InternetExplorerDriverLogLevel.valueOf(logLevel.toUpperCase())); if (host != null) builder.withHost(host); if (extractPath != null) builder.withExtractPath(extractPath); if (silent != null) builder.withSilent(silent); return builder.build(); } }
private static InternetExplorerDriverService.Builder setServiceExecutablePath(BrowserConfig browserConfig, InternetExplorerDriverService.Builder builder) { if (hasServicePath(browserConfig)) { File profilePath = new File(browserConfig.getProfilePath()); File ieDriverFile = new File(profilePath, IE_SERVICE_EXECUTABLE); if (ieDriverFile.isFile()) { builder.usingDriverExecutable(ieDriverFile); } } return builder; }
InternetExplorerDriverService.Builder serviceBuilder = new InternetExplorerDriverService.Builder().usingAnyFreePort(); InternetExplorerDriverService service = serviceBuilder.build(); WebDriver ie = new InternetExplorerDriver(service); // Open your URL: ie.get("http://www.google.com");
@Override public WebDriver newInstance(DriverOptions driverOptions) { if (!OS.isFamilyWindows()) throw new UnsupportedOperationException("Unsupported platform: " + Platform.getCurrent()); InternetExplorerDriverService service = setupBuilder(new InternetExplorerDriverService.Builder(), driverOptions, IEDRIVER).build(); InternetExplorerOptions options = newInternetExplorerOptions(driverOptions); options.merge(driverOptions.getCapabilities()); InternetExplorerDriver driver = new InternetExplorerDriver(service, options); setInitialWindowSize(driver, driverOptions); return driver; } }
/** * Configures and returns a new {@link InternetExplorerDriverService} using the default configuration. In * this configuration, the service will use the IEDriverServer executable identified by the * {@link #IE_DRIVER_EXE_PROPERTY} system property. Each service created by this method will * be configured to use a free port on the current system. * * @return A new InternetExplorerDriverService using the default configuration. */ public static InternetExplorerDriverService createDefaultService() { return new Builder().build(); }
@Override protected InternetExplorerDriverService newDriverService() { InternetExplorerDriverService newService = new InternetExplorerDriverService.Builder() .usingDriverExecutable(driverExecutable()) .usingAnyFreePort() .build(); DriverPathConfiguration.updateSystemProperty(WEBDRIVER_IE_DRIVER.getPropertyName()) .withExecutablePath(driverExecutable()); Runtime.getRuntime().addShutdownHook(new StopServiceHook(newService)); return newService; }