Skip to main content

Setting Browser Options

Selenium lets you set browser arguments for Chromium based browsers. When selecting Chrome, Firefox, and Edge, you can set browser options using ChromeOptions, EdgeOptions, and FirefoxOptions capability as shown below.

    import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class ChromeTest {
public static void main(String[] args) {
ChromeOptions options = new ChromeOptions();
// Set Chrome capabilities
options.addArguments("--headless");

WebDriver driver = new ChromeDriver(options);
driver.get("http://example.com");
// Your test code here
driver.quit();
}
}

Desired Capability to Automate IE Mode in Microsoft Edge

LambdaTest's Automation allows you to automate IE Mode in Microsoft Edge on Windows 11. You can pass the below desired capability in your test script and execute your tests.

InternetExplorerOptions browserOptions = new InternetExplorerOptions();
browserOptions.setPlatformName("Windows 11");
browserOptions.setBrowserVersion("11.0");
HashMap<String, Object> ltOptions = new HashMap<String, Object>();
ltOptions.put("username", "Your LambdaTest Username");
ltOptions.put("accessKey", "Your LambdaTest Access Key");
ltOptions.put("project", "Untitled");
ltOptions.put("w3c", true);
browserOptions.setCapability("LT:Options", ltOptions);

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles