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)
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.
yes
@Djoneslildaj sorry, I just updated my comment.
Using the
--window-sizearg seems to work in both headless and regular mode.The issue is using
--start-maximizedormaximize_window()in headless mode. That is a known limitation of Chrome. The workaround is to set it to a specific size.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,hsyntax is what is used in the current chromium code.