EdgeDriverService service = new EdgeDriverService.Builder() .usingDriverExecutable(new File("path/to/my/MicrosoftWebDriver.exe")) .usingAnyFreePort() .build(); service.start(); WebDriver driver = new RemoteWebDriver(service.getUrl(), DesiredCapabilities.edge()); driver.get("www.google.com");
@Override protected ImmutableList<String> createArgs() { ImmutableList.Builder<String> argsBuilder = ImmutableList.builder(); argsBuilder.add(String.format("--port=%d", getPort())); if (Boolean.getBoolean(EDGE_DRIVER_VERBOSE_LOG_PROPERTY)) { argsBuilder.add("--verbose"); } return argsBuilder.build(); }
@Override protected EdgeDriverService createDriverService(File exe, int port, ImmutableList<String> args, ImmutableMap<String, String> environment) { try { EdgeDriverService service = new EdgeDriverService(exe, port, args, environment); if (getLogFile() != null) { service.sendOutputTo(new FileOutputStream(getLogFile())); } else { String logFile = System.getProperty(EDGE_DRIVER_LOG_PROPERTY); if (logFile != null) { service.sendOutputTo(new FileOutputStream(logFile)); } } return service; } catch (IOException e) { throw new WebDriverException(e); } } }
/** * Configures and returns a new {@link EdgeDriverService} using the default configuration. In * this configuration, the service will use the MicrosoftWebDriver executable identified by the * {@link #EDGE_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 EdgeDriverService using the default configuration. */ public static EdgeDriverService createDefaultService() { return new Builder().build(); }
@Override protected EdgeDriverService newDriverService() { EdgeDriverService newService = new EdgeDriverService.Builder() .usingDriverExecutable(edgeDriverExecutable()) .usingAnyFreePort() .build(); DriverPathConfiguration.updateSystemProperty(WEBDRIVER_EDGE_DRIVER.getPropertyName()) .withExecutablePath(edgeDriverExecutable()); Runtime.getRuntime().addShutdownHook(new StopServiceHook(newService)); return newService; }
@Override public WebDriver newInstance(DriverOptions driverOptions) { if (!OS.isFamilyWindows()) throw new UnsupportedOperationException("Unsupported platform: " + Platform.getCurrent()); EdgeDriverService service = setupBuilder(new EdgeDriverService.Builder(), driverOptions, EDGEDRIVER).build(); EdgeOptions options = newEdgeOptions(driverOptions); options.merge(driverOptions.getCapabilities()); EdgeDriver driver = new EdgeDriver(service, options); setInitialWindowSize(driver, driverOptions); return driver; } }