selenium: [🐛 Bug]: ChromeOptions for window size not working with Chrome 137.0.7151.68-1 on Linux using Selenium v4.33.

Description

Summary:

Setting window resolution via chrome_options.add_argument(“–window-size=1920,1080”) does not take effect when using Chrome 137.0.7151.68-1 on a Linux machine in headless mode.

Environment

OS: RHEL Linux (Ubuntu 22.04)
Chrome Version: 137.0.7151.68-1
Selenium Version: 4.33
Python Version: 3.13.3

Reproduction Steps

1. Code: Run the code below       

2. Observe the output window size.

Expected Behaviour - The browser window should open with a resolution of 1920,1080.

Actual Behaviour - The browser opens in a smaller default size (e.g., ~800x600), ignoring the --window-size argument.

Reproducible Code

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("--window-size=1920,1080")
driver = webdriver.Chrome(options=options)
driver.get("https://example.com")
print(driver.get_window_size())
driver.quit()

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 42 (16 by maintainers)

Most upvoted comments

Oh okay then it might be blocker for you. Anyways i have raised this issue at chrome browser end and awaiting their response. If i get any feedback will update here as well.

Are you stating that I should use set_window_size instead of the browser.maximize_window()?

yes

@Djoneslildaj sorry, I just updated my comment.

Using the --window-size arg seems to work in both headless and regular mode.

The issue is using --start-maximized or maximize_window() in headless mode. That is a known limitation of Chrome. The workaround is to set it to a specific size.

Thank you. I think headless mode is not working at all. I removed the window size and it still did not work, options = webdriver.ChromeOptions() options.add_argument(‘–headless=new’) options.add_argument(‘ignore-certificate-errors’) options.add_experimental_option(‘excludeSwitches’, [‘enable-logging’]) browser = webdriver.Chrome(options=options) browser.maximize_window()

As you stated this may be an issue with Chrome. Is there a work around perhaps that can be used until Chrome fix is available?

You can use lower version of chrome like 136. That works for me.

It is possible they changed support for the other syntax, but the w,h syntax is what is used in the current chromium code.