CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-seleniumhq-selenium--selenium-edge-driver

Microsoft Edge WebDriver implementation for Selenium WebDriver browser automation with EdgeOptions configuration and EdgeDriverService management.

Pending
Overview
Eval results
Files

edge-driver-info.mddocs/

Edge Driver Info

EdgeDriverInfo provides metadata, capability matching, and factory methods for EdgeDriver instances. It integrates with Selenium's WebDriverInfo service provider interface to enable automatic driver selection and creation based on browser capabilities.

Capabilities

EdgeDriverInfo Class

Metadata provider and factory for EdgeDriver instances with capability matching and WebDriver integration.

/**
 * WebDriverInfo implementation for Microsoft Edge browser
 * Provides metadata and factory methods for EdgeDriver instances
 */
@AutoService(WebDriverInfo.class)
public class EdgeDriverInfo extends ChromiumDriverInfo {
    /**
     * Gets human-readable display name for Edge
     * @return "Edge"
     */
    public String getDisplayName();
    
    /**
     * Gets canonical capabilities for Edge browser
     * @return ImmutableCapabilities with browserName set to "MicrosoftEdge"
     */
    public Capabilities getCanonicalCapabilities();
    
    /**
     * Checks if given capabilities are supported by EdgeDriver
     * @param capabilities Capabilities to check
     * @return true if capabilities are supported (Edge, WebView2, or ms:edgeOptions)
     */
    public boolean isSupporting(Capabilities capabilities);
    
    /**
     * Checks if EdgeDriver supports Chrome DevTools Protocol
     * @return true (EdgeDriver supports CDP)
     */
    public boolean isSupportingCdp();
    
    /**
     * Checks if EdgeDriver supports WebDriver BiDi protocol
     * @return true (EdgeDriver supports BiDi)
     */
    public boolean isSupportingBiDi();
    
    /**
     * Checks if EdgeDriver executable is available on the system
     * @return true if msedgedriver is available and can be executed
     */
    public boolean isAvailable();
    
    /**
     * Checks if EdgeDriver executable is present on the system
     * @return true if msedgedriver executable exists
     */
    public boolean isPresent();
    
    /**
     * Creates EdgeDriver instance if capabilities are supported and driver is available
     * @param capabilities Desired capabilities for the driver
     * @return Optional containing EdgeDriver if creation successful, empty otherwise
     * @throws SessionNotCreatedException if driver cannot be created
     */
    public Optional<WebDriver> createDriver(Capabilities capabilities) throws SessionNotCreatedException;
}

Usage Examples:

import org.openqa.selenium.edge.EdgeDriverInfo;
import org.openqa.selenium.edge.EdgeOptions;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;

// Get driver info instance
EdgeDriverInfo driverInfo = new EdgeDriverInfo();

// Check basic information
String displayName = driverInfo.getDisplayName(); // "Edge"
Capabilities canonical = driverInfo.getCanonicalCapabilities();

// Check capabilities and availability
boolean available = driverInfo.isAvailable();
boolean present = driverInfo.isPresent();
boolean supportsCdp = driverInfo.isSupportingCdp(); // true
boolean supportsBidi = driverInfo.isSupportingBiDi(); // true

Capability Matching

EdgeDriverInfo supports multiple capability patterns for Edge and WebView2:

/**
 * Supported capability patterns:
 * - browserName: "MicrosoftEdge"
 * - browserName: "webview2" 
 * - ms:edgeOptions capability present
 */
public boolean isSupporting(Capabilities capabilities);

Usage Examples:

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

// Edge browser capabilities
Capabilities edgeCapabilities = new ImmutableCapabilities(
    CapabilityType.BROWSER_NAME, "MicrosoftEdge"
);
boolean supportsEdge = driverInfo.isSupporting(edgeCapabilities); // true

// WebView2 capabilities
Capabilities webViewCapabilities = new ImmutableCapabilities(
    CapabilityType.BROWSER_NAME, "webview2"
);
boolean supportsWebView = driverInfo.isSupporting(webViewCapabilities); // true

// EdgeOptions capabilities
EdgeOptions options = new EdgeOptions();
boolean supportsOptions = driverInfo.isSupporting(options); // true

// Unsupported browser
Capabilities chromeCapabilities = new ImmutableCapabilities(
    CapabilityType.BROWSER_NAME, "chrome"
);
boolean supportsChrome = driverInfo.isSupporting(chromeCapabilities); // false

Driver Creation

Factory method for creating EdgeDriver instances with capability validation:

/**
 * Creates EdgeDriver if capabilities are supported and driver is available
 * @param capabilities Desired capabilities
 * @return Optional<WebDriver> containing EdgeDriver or empty if cannot create
 */
public Optional<WebDriver> createDriver(Capabilities capabilities);

Usage Examples:

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

// Create driver with Edge capabilities
EdgeOptions options = new EdgeOptions();
options.addArguments("--headless");

Optional<WebDriver> driverOptional = driverInfo.createDriver(options);
if (driverOptional.isPresent()) {
    WebDriver driver = driverOptional.get();
    driver.get("https://example.com");
    driver.quit();
} else {
    System.out.println("Cannot create EdgeDriver - not available or unsupported");
}

// Create WebView2 driver
EdgeOptions webViewOptions = new EdgeOptions();
webViewOptions.useWebView(true);

Optional<WebDriver> webViewDriver = driverInfo.createDriver(webViewOptions);
if (webViewDriver.isPresent()) {
    WebDriver driver = webViewDriver.get();
    // Use for WebView2 automation
    driver.quit();
}

System Availability Checking

Methods to verify EdgeDriver executable availability:

/**
 * Checks if EdgeDriver is available (executable exists and can run)
 * @return true if msedgedriver is available
 */
public boolean isAvailable();

/**
 * Checks if EdgeDriver is present (executable file exists)
 * @return true if msedgedriver executable exists
 */
public boolean isPresent();

Usage Examples:

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

// Check driver availability before creating tests
if (driverInfo.isAvailable()) {
    System.out.println("EdgeDriver is available and ready to use");
    
    // Run Edge automation tests
    EdgeDriver driver = new EdgeDriver();
    // ... test code
    driver.quit();
    
} else if (driverInfo.isPresent()) {
    System.out.println("EdgeDriver executable found but may not be functional");
} else {
    System.out.println("EdgeDriver not found - please install msedgedriver");
}

// Use in test setup
@BeforeClass
public static void checkDriverAvailability() {
    EdgeDriverInfo info = new EdgeDriverInfo();
    Assume.assumeTrue("EdgeDriver not available", info.isAvailable());
}

Protocol Support Checking

Methods to verify protocol support capabilities:

/**
 * Checks Chrome DevTools Protocol support
 * @return true (EdgeDriver supports CDP)
 */
public boolean isSupportingCdp();

/**
 * Checks WebDriver BiDi protocol support  
 * @return true (EdgeDriver supports BiDi)
 */
public boolean isSupportingBiDi();

Usage Examples:

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

// Check CDP support for advanced debugging
if (driverInfo.isSupportingCdp()) {
    EdgeDriver driver = new EdgeDriver();
    
    // Use CDP features
    DevTools devTools = driver.getDevTools();
    devTools.createSession();
    // ... CDP operations
    
    driver.quit();
}

// Check BiDi support for modern WebDriver features
if (driverInfo.isSupportingBiDi()) {
    // Use WebDriver BiDi features when available
    System.out.println("BiDi protocol supported");
}

Integration with WebDriverManager

EdgeDriverInfo integrates with Selenium's service provider interface:

// EdgeDriverInfo is automatically discovered via @AutoService annotation
// and can be used by WebDriverManager for automatic driver selection

ServiceLoader<WebDriverInfo> drivers = ServiceLoader.load(WebDriverInfo.class);
for (WebDriverInfo driverInfo : drivers) {
    if (driverInfo instanceof EdgeDriverInfo) {
        EdgeDriverInfo edgeInfo = (EdgeDriverInfo) driverInfo;
        if (edgeInfo.isAvailable()) {
            // EdgeDriver is available for use
        }
    }
}

Error Handling

EdgeDriverInfo throws standard exceptions during driver creation:

// Common exceptions
SessionNotCreatedException - When EdgeDriver session cannot be created
WebDriverException - General driver creation errors
IllegalArgumentException - Invalid capabilities provided

Usage Examples:

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

try {
    EdgeOptions options = new EdgeOptions();
    // Invalid binary path
    options.setBinary("/nonexistent/path/to/edge");
    
    Optional<WebDriver> driver = driverInfo.createDriver(options);
    if (driver.isEmpty()) {
        System.out.println("Driver creation failed - check capabilities and availability");
    }
    
} catch (SessionNotCreatedException e) {
    System.err.println("Cannot create Edge session: " + e.getMessage());
} catch (WebDriverException e) {
    System.err.println("Edge driver error: " + e.getMessage());
}

Types

import org.openqa.selenium.WebDriverInfo;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ImmutableCapabilities;
import org.openqa.selenium.SessionNotCreatedException;
import org.openqa.selenium.chromium.ChromiumDriverInfo;
import org.openqa.selenium.remote.CapabilityType;
import com.google.auto.service.AutoService;
import java.util.Optional;

Install with Tessl CLI

npx tessl i tessl/maven-org-seleniumhq-selenium--selenium-edge-driver

docs

edge-driver-info.md

edge-driver-service.md

edge-driver.md

edge-options.md

index.md

tile.json