Microsoft Edge WebDriver implementation for Selenium WebDriver browser automation with EdgeOptions configuration and EdgeDriverService management.
—
EdgeDriverService manages the lifecycle of the EdgeDriver executable (msedgedriver) with extensive configuration options for logging, networking, security, and operational behavior. It handles automatic driver detection, port management, and process lifecycle.
Service management class for EdgeDriver executable lifecycle and configuration.
/**
* Manages the life and death of the MSEdgeDriver executable
*/
public class EdgeDriverService extends DriverService {
public static final String EDGE_DRIVER_NAME = "msedgedriver";
public static final String EDGE_DRIVER_EXE_PROPERTY = "webdriver.edge.driver";
public static final String EDGE_DRIVER_READABLE_TIMESTAMP = "webdriver.edge.readableTimestamp";
public static final String EDGE_DRIVER_LOG_PROPERTY = "webdriver.edge.logfile";
public static final String EDGE_DRIVER_LOG_LEVEL_PROPERTY = "webdriver.edge.loglevel";
public static final String EDGE_DRIVER_APPEND_LOG_PROPERTY = "webdriver.edge.appendLog";
public static final String EDGE_DRIVER_VERBOSE_LOG_PROPERTY = "webdriver.edge.verboseLogging";
public static final String EDGE_DRIVER_SILENT_OUTPUT_PROPERTY = "webdriver.edge.silentOutput";
public static final String EDGE_DRIVER_ALLOWED_IPS_PROPERTY = "webdriver.edge.withAllowedIps";
public static final String EDGE_DRIVER_DISABLE_BUILD_CHECK = "webdriver.edge.disableBuildCheck";
/**
* Creates EdgeDriverService with full configuration
* @param executable EdgeDriver executable file
* @param port Port number for the service
* @param timeout Timeout for driver startup
* @param args Command line arguments for the driver
* @param environment Environment variables for the driver process
*/
public EdgeDriverService(File executable, int port, Duration timeout,
List<String> args, Map<String, String> environment) throws IOException;
/**
* Gets the driver executable name
* @return "msedgedriver"
*/
public String getDriverName();
/**
* Gets the system property key for driver executable location
* @return "webdriver.edge.driver"
*/
public String getDriverProperty();
/**
* Gets default driver options
* @return new EdgeOptions instance
*/
public Capabilities getDefaultDriverOptions();
/**
* Creates service with default configuration
* @return EdgeDriverService with default settings
*/
public static EdgeDriverService createDefaultService();
}Usage Examples:
import org.openqa.selenium.edge.EdgeDriverService;
import java.time.Duration;
import java.util.Arrays;
import java.util.HashMap;
// Default service
EdgeDriverService service = EdgeDriverService.createDefaultService();
// Custom service with full configuration
File executable = new File("/path/to/msedgedriver");
int port = 9515;
Duration timeout = Duration.ofSeconds(30);
List<String> args = Arrays.asList("--port=9515", "--verbose");
Map<String, String> env = new HashMap<>();
env.put("DISPLAY", ":0");
EdgeDriverService customService = new EdgeDriverService(
executable, port, timeout, args, env
);Builder class for creating configured EdgeDriverService instances.
/**
* Builder for configuring EdgeDriverService instances
*/
public static class Builder extends DriverService.Builder<EdgeDriverService, Builder> {
/**
* Configures log file appending behavior
* @param appendLog true to append to existing log file
* @return this Builder instance for method chaining
*/
public Builder withAppendLog(boolean appendLog);
/**
* Disables build version compatibility checking
* @param noBuildCheck true to disable build version checks
* @return this Builder instance for method chaining
*/
public Builder withBuildCheckDisabled(boolean noBuildCheck);
/**
* Sets driver logging level
* @param logLevel ChromiumDriverLogLevel for output verbosity
* @return this Builder instance for method chaining
*/
public Builder withLoglevel(ChromiumDriverLogLevel logLevel);
/**
* Configures silent output mode
* @param silent true to suppress driver output
* @return this Builder instance for method chaining
*/
public Builder withSilent(boolean silent);
/**
* Configures verbose output mode
* @param verbose true to enable detailed driver output
* @return this Builder instance for method chaining
*/
public Builder withVerbose(boolean verbose);
/**
* Sets allowed IP addresses for connections
* @param allowedListIps comma-separated list of allowed IPv4 addresses
* @return this Builder instance for method chaining
*/
public Builder withAllowedListIps(String allowedListIps);
/**
* Configures timestamp format in logs
* @param readableTimestamp true for human-readable timestamps
* @return this Builder instance for method chaining
*/
public Builder withReadableTimestamp(Boolean readableTimestamp);
/**
* Builds the configured EdgeDriverService
* @return configured EdgeDriverService instance
*/
public EdgeDriverService build();
}Usage Examples:
import org.openqa.selenium.edge.EdgeDriverService;
import org.openqa.selenium.chromium.ChromiumDriverLogLevel;
// Basic builder usage
EdgeDriverService service = new EdgeDriverService.Builder()
.usingPort(9515)
.build();
// Advanced configuration
EdgeDriverService advancedService = new EdgeDriverService.Builder()
.usingDriverExecutable(new File("/custom/path/msedgedriver"))
.usingPort(4444)
.withTimeout(Duration.ofSeconds(60))
.withLogFile(new File("edge-driver.log"))
.withLoglevel(ChromiumDriverLogLevel.DEBUG)
.withVerbose(true)
.withAppendLog(true)
.withReadableTimestamp(true)
.withAllowedListIps("127.0.0.1,192.168.1.100")
.withBuildCheckDisabled(true)
.build();
// Use with EdgeDriver
EdgeDriver driver = new EdgeDriver(advancedService);EdgeDriverService inherits standard service lifecycle methods:
/**
* Starts the driver service
* @throws IOException if service cannot be started
*/
public void start() throws IOException;
/**
* Stops the driver service
*/
public void stop();
/**
* Checks if service is currently running
* @return true if service is running
*/
public boolean isRunning();
/**
* Gets the service URL
* @return URL of the running service
*/
public URL getUrl();
/**
* Gets the service port
* @return port number of the service
*/
public int getPort();
/**
* Gets command line arguments used to start the service
* @return list of command line arguments
*/
public List<String> getArgs();Usage Examples:
EdgeDriverService service = EdgeDriverService.createDefaultService();
// Manual service lifecycle management
service.start();
boolean running = service.isRunning();
URL serviceUrl = service.getUrl();
int port = service.getPort();
// Use service with driver
EdgeDriver driver = new EdgeDriver(service);
driver.get("https://example.com");
driver.quit();
// Stop service when done
service.stop();Builder inherits configuration methods from DriverService.Builder:
/**
* Sets the driver executable file
* @param file Driver executable file
* @return this Builder instance for method chaining
*/
public Builder usingDriverExecutable(File file);
/**
* Sets the service port number
* @param port Port number for the service
* @return this Builder instance for method chaining
*/
public Builder usingPort(int port);
/**
* Sets any free port for the service
* @return this Builder instance for method chaining
*/
public Builder usingAnyFreePort();
/**
* Sets service startup timeout
* @param timeout Duration to wait for service startup
* @return this Builder instance for method chaining
*/
public Builder withTimeout(Duration timeout);
/**
* Sets log file for driver output
* @param logFile File to write driver logs
* @return this Builder instance for method chaining
*/
public Builder withLogFile(File logFile);
/**
* Sets environment variables for driver process
* @param environment Map of environment variable names to values
* @return this Builder instance for method chaining
*/
public Builder withEnvironment(Map<String, String> environment);Usage Examples:
EdgeDriverService service = new EdgeDriverService.Builder()
.usingDriverExecutable(new File("/opt/msedgedriver"))
.usingPort(8080)
.withTimeout(Duration.ofMinutes(2))
.withLogFile(new File("/var/log/edge-driver.log"))
.withEnvironment(Map.of(
"DISPLAY", ":1",
"LANG", "en_US.UTF-8"
))
.build();Configure driver logging behavior with ChromiumDriverLogLevel:
// Log levels
enum ChromiumDriverLogLevel {
OFF, SEVERE, WARNING, INFO, DEBUG, ALL
}Usage Examples:
// Different logging configurations
EdgeDriverService debugService = new EdgeDriverService.Builder()
.withLoglevel(ChromiumDriverLogLevel.DEBUG)
.withVerbose(true)
.withLogFile(new File("debug.log"))
.build();
EdgeDriverService silentService = new EdgeDriverService.Builder()
.withLoglevel(ChromiumDriverLogLevel.OFF)
.withSilent(true)
.build();
EdgeDriverService infoService = new EdgeDriverService.Builder()
.withLoglevel(ChromiumDriverLogLevel.INFO)
.withReadableTimestamp(true)
.withAppendLog(false)
.build();EdgeDriverService automatically reads configuration from system properties:
// Set system properties before creating service
System.setProperty("webdriver.edge.driver", "/path/to/msedgedriver");
System.setProperty("webdriver.edge.logfile", "/var/log/edge.log");
System.setProperty("webdriver.edge.loglevel", "DEBUG");
System.setProperty("webdriver.edge.verboseLogging", "true");
System.setProperty("webdriver.edge.silentOutput", "false");
System.setProperty("webdriver.edge.withAllowedIps", "127.0.0.1");
System.setProperty("webdriver.edge.disableBuildCheck", "true");
System.setProperty("webdriver.edge.readableTimestamp", "true");
System.setProperty("webdriver.edge.appendLog", "true");
// Service will automatically use these properties
EdgeDriverService service = EdgeDriverService.createDefaultService();EdgeDriverService throws standard exceptions:
// Common exceptions
IOException - When service cannot start or stop
WebDriverException - General service-related errors
IllegalStateException - When service is in invalid stateUsage Examples:
try {
EdgeDriverService service = new EdgeDriverService.Builder()
.usingPort(9515)
.withLogFile(new File("/invalid/path/edge.log"))
.build();
service.start();
EdgeDriver driver = new EdgeDriver(service);
} catch (IOException e) {
System.err.println("Failed to start service: " + e.getMessage());
} catch (WebDriverException e) {
System.err.println("Driver service error: " + e.getMessage());
} finally {
if (service != null && service.isRunning()) {
service.stop();
}
}import org.openqa.selenium.remote.service.DriverService;
import org.openqa.selenium.chromium.ChromiumDriverLogLevel;
import org.openqa.selenium.WebDriverException;
import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.net.URL;Install with Tessl CLI
npx tessl i tessl/maven-org-seleniumhq-selenium--selenium-edge-driver