Selenium + Python · Lesson 31 of 43

0/43 done

Module 31: Browser Options & Capabilities

31. ChromeOptions, Headless Execution & Custom Profiles

16 minlesson

Your task

Implement build_headless_chrome_options():

  1. Create Options().
  2. Add arguments "--headless=new" and "--window-size=1920,1080".
  3. Return the options object.

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

Configuring ChromeOptions in Python

python
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("--headless=new")
options.add_argument("--window-size=1920,1080")
options.add_argument("--disable-notifications")
options.add_argument("--incognito")

driver = webdriver.Chrome(options=options)

Key Takeaways & Walkthrough Summary

Running tests on headless servers and configuring custom capabilities requires browser Options classes. In this lesson, you will master ChromeOptions with --headless=new and configuring window sizes. Let's configure browser options!

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

Common Doubts & Lesson Q&A

Why is '--headless=new' preferred over '--headless'?

In Chrome 109+, '--headless=new' uses the modern rendering engine, behaving identically to the real user browser.

Ready? Solve the task in the editor

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

Python
Skip