Setting up Microsoft Edge in headless mode with Selenium

I need to run my web application tests using Microsoft Edge in headless mode but I’m having trouble finding the right configuration. I’ve searched online but couldn’t find clear instructions for my setup.

My current environment:

  • Windows 10
  • Selenium 3.141.59
  • Java 11
  • Edge Browser 88.0.705.81 (Chromium-based)
  • EdgeDriver 88.0.705.81

I found some code snippets online but they don’t work with my Java and Edge combination:

EdgeOptions options = new EdgeOptions();
options.useChromium = true;
options.addArguments("headless");

My IDE shows errors for these lines. Can someone help me with the correct way to configure Edge browser options for headless execution? I just need to launch the browser without GUI and navigate to my application URL.

Any working code examples would be really helpful. Thanks in advance!

had the same issue last week. your headless syntax is wrong - use options.addArguments("--headless"); instead of just "headless". also check that edgedriver.exe is in the right path or set the system property System.setProperty("webdriver.edge.driver", "path/to/edgedriver.exe"); before creating the driver.

You’re encountering this issue due to using deprecated Selenium methods. The useChromium property no longer exists; since Edge has transitioned to a Chromium base, it’s already integrated. To resolve this, try the following setup:

EdgeOptions options = new EdgeOptions();
options.addArguments("--headless", "--disable-gpu", "--no-sandbox");
WebDriver driver = new EdgeDriver(options);

Including these additional arguments can enhance the stability of headless mode. Furthermore, ensure that your EdgeDriver version aligns precisely with your installed browser version, as mismatches often lead to tricky initialization problems.

To configure Microsoft Edge in headless mode for your Selenium tests, ensure you’re using the correct syntax for your setup. Here’s a simple solution:

EdgeOptions options = new EdgeOptions();
options.setCapability("ms:edgeOptions", Map.of("args", Arrays.asList("--headless")));
WebDriver driver = new EdgeDriver(options);

Alternatively, you can directly add the argument:

EdgeOptions options = new EdgeOptions();
options.addArguments("--headless");
WebDriver driver = new EdgeDriver(options);

Don’t forget to ensure that EdgeDriver is included in your system PATH for smooth execution.