EdgeOptions lets you set up how the Microsoft Edge browser should behave during automated tests. It helps control browser settings easily.
0
0
EdgeOptions configuration in Selenium Java
Introduction
When you want to start Edge browser with specific settings like headless mode.
When you need to add browser arguments such as disabling extensions for faster tests.
When you want to set preferences like download folder or pop-up blocking.
When you want to run tests on Edge with custom capabilities.
When you want to control Edge browser behavior to avoid test flakiness.
Syntax
Selenium Java
EdgeOptions options = new EdgeOptions(); options.addArguments("--start-maximized"); options.setCapability("someCapability", true);
Use addArguments to pass command line switches to Edge.
Use setCapability to set specific browser capabilities.
Examples
This example runs Edge in headless mode, which means no browser window shows up.
Selenium Java
EdgeOptions options = new EdgeOptions();
options.addArguments("--headless");This disables all browser extensions to avoid interference during tests.
Selenium Java
EdgeOptions options = new EdgeOptions();
options.addArguments("--disable-extensions");This allows Edge to accept insecure SSL certificates during testing.
Selenium Java
EdgeOptions options = new EdgeOptions();
options.setCapability("acceptInsecureCerts", true);Sample Program
This test opens Edge maximized, accepts insecure certificates, navigates to example.com, prints the page title, then closes the browser.
Selenium Java
import org.openqa.selenium.edge.EdgeDriver; import org.openqa.selenium.edge.EdgeOptions; public class EdgeOptionsTest { public static void main(String[] args) { EdgeOptions options = new EdgeOptions(); options.addArguments("--start-maximized"); options.setCapability("acceptInsecureCerts", true); EdgeDriver driver = new EdgeDriver(options); driver.get("https://example.com"); String title = driver.getTitle(); System.out.println("Page title is: " + title); driver.quit(); } }
OutputSuccess
Important Notes
Always quit the driver to close the browser and free resources.
Use meaningful arguments to control browser behavior for stable tests.
Check EdgeDriver version compatibility with your Edge browser version.
Summary
EdgeOptions configures Microsoft Edge browser settings for automated tests.
Use addArguments and setCapability to customize behavior.
Proper configuration helps tests run smoothly and reliably.