Selenium + Java · Lesson 32 of 44

0/44 done

Module 32: Browser Options & Capabilities

32. ChromeOptions, Headless Execution & Custom Browser Capabilities

16 minlesson

Your task

Implement createHeadlessChromeOptions:

  1. Return new ChromeOptions with arguments "--headless=new" and "--window-size=1920,1080".

Write it in the editor, then press Check answer (Ctrl + Enter).

ChromeOptions Configuration

java
import org.openqa.selenium.chrome.ChromeOptions;

ChromeOptions options = new ChromeOptions();
options.addArguments("--headless=new"); // Modern headless mode in Chrome
options.addArguments("--window-size=1920,1080");
options.addArguments("--disable-notifications");
options.addArguments("--incognito");

WebDriver driver = new ChromeDriver(options);

Key Takeaways & Walkthrough Summary

CI pipelines execute tests headlessly without display hardware. In this lesson, you will configure ChromeOptions with arguments like --headless, --disable-notifications, and configure default download directories. Let's master browser options!

Part of the Selenium + Java course (Selenium with Java). Practice this concept live in the Selenium Online Compiler or explore our free automation practice form.

Common Doubts & Lesson Q&A

What is the difference between '--headless' and '--headless=new'?

In Chrome 109+, '--headless=new' uses the unified browser architecture, matching normal Chrome rendering and reducing headless-only test bugs.

Ready? Solve the task in the editor

Use Check answer to mark it complete. Hints are there if you need them.

Java
Skip