Skip to content

[🐛 Bug]: [py] Can't set small window size #15590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cgoldberg opened this issue Apr 7, 2025 · 2 comments
Open

[🐛 Bug]: [py] Can't set small window size #15590

cgoldberg opened this issue Apr 7, 2025 · 2 comments
Labels
A-needs-triaging A Selenium member will evaluate this soon! C-py Python Bindings D-chrome I-defect Something is not working as intended OS-linux

Comments

@cgoldberg
Copy link
Contributor

cgoldberg commented Apr 7, 2025

Description

I can't set the browser window size to small values (i.e. 400x400) with Chrome. For example,driver.set_window_size(400, 400) has no effect, but driver.set_window_size(600, 600) works fine?

Is there some kind of a minimum for changing window size? If so, perhaps we can raise an error if requesting a window size that is too small.

This is probably a ChromeDriver issue, but wanted to report it here.

Update:

Pretty much every browser handles this weird, but can set larger window sizes fine. Unlike Chrome (which doesn't resize at all), the other browsers resize to something different than what I request. (Not sure if the size I request only accounts for the viewport, but the entire browser is included in the size it returns? But why does it work for larger sizes?)

To summarize:
calling driver.set_window_size(400, 400) with Chrome returns: {'width': 1050, 'height': 844}
calling driver.set_window_size(400, 400) with Edge returns: {'width': 501, 'height': 400}
calling driver.set_window_size(400, 400) with Firefox returns: {'width': 488, 'height': 400}
calling driver.set_window_size(400, 400) with WebKitGTK returns: {'width': 462, 'height': 400}

Reproducible Code

driver = webdriver.Chrome()
driver.set_window_size(400, 400)
print(driver.get_window_size())

Debugging Logs

DEBUG:selenium.webdriver.common.selenium_manager:Selenium Manager binary found at: /home/cgoldberg617/code/selenium/py/selenium/webdriver/common/linux/selenium-manager
DEBUG:selenium.webdriver.common.selenium_manager:Executing process: /home/cgoldberg617/code/selenium/py/selenium/webdriver/common/linux/selenium-manager --browser chrome --debug --language-binding python --output json
DEBUG:selenium.webdriver.common.selenium_manager:chromedriver not found in PATH
DEBUG:selenium.webdriver.common.selenium_manager:chrome not found in PATH
DEBUG:selenium.webdriver.common.selenium_manager:chrome not found in the system
DEBUG:selenium.webdriver.common.selenium_manager:Required browser: chrome 135.0.7049.42
DEBUG:selenium.webdriver.common.selenium_manager:chrome 135.0.7049.42 already exists
DEBUG:selenium.webdriver.common.selenium_manager:chrome 135.0.7049.42 is available at /home/cgoldberg617/.cache/selenium/chrome/linux64/135.0.7049.42/chrome
DEBUG:selenium.webdriver.common.selenium_manager:Required driver: chromedriver 135.0.7049.42
DEBUG:selenium.webdriver.common.selenium_manager:chromedriver 135.0.7049.42 already in the cache
DEBUG:selenium.webdriver.common.selenium_manager:Driver path: /home/cgoldberg617/.cache/selenium/chromedriver/linux64/135.0.7049.42/chromedriver
DEBUG:selenium.webdriver.common.selenium_manager:Browser path: /home/cgoldberg617/.cache/selenium/chrome/linux64/135.0.7049.42/chrome
DEBUG:selenium.webdriver.common.service:Started executable: `/home/cgoldberg617/.cache/selenium/chromedriver/linux64/135.0.7049.42/chromedriver` in a child process with pid: 741 using 0 to output -3
DEBUG:selenium.webdriver.remote.remote_connection:POST http://localhost:39455/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'chrome', 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'browserVersion': None, 'goog:chromeOptions': {'extensions': [], 'binary': '/home/cgoldberg617/.cache/selenium/chrome/linux64/135.0.7049.42/chrome', 'args': []}}}}
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): localhost:39455
DEBUG:urllib3.connectionpool:http://localhost:39455 "POST /session HTTP/1.1" 200 0
DEBUG:selenium.webdriver.remote.remote_connection:Remote response: status=200 | data={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"135.0.7049.42","chrome":{"chromedriverVersion":"135.0.7049.42 (0f351bbd2617e0f775543271f34b7d241f8ebcdc-refs/branch-heads/7049@{#1349})","userDataDir":"/tmp/.org.chromium.Chromium.kg7426"},"fedcm:accounts":true,"goog:chromeOptions":{"debuggerAddress":"localhost:39909"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"linux","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":true,"webauthn:extension:largeBlob":true,"webauthn:extension:minPinLength":true,"webauthn:extension:prf":true,"webauthn:virtualAuthenticators":true},"sessionId":"deb05f0fcfaf8cfa21b8fc6b09d1a7af"}} | headers=HTTPHeaderDict({'Content-Length': '848', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:selenium.webdriver.remote.remote_connection:Finished Request
DEBUG:selenium.webdriver.remote.remote_connection:POST http://localhost:39455/session/deb05f0fcfaf8cfa21b8fc6b09d1a7af/window/rect {'x': None, 'y': None, 'width': 400, 'height': 400}
DEBUG:urllib3.connectionpool:http://localhost:39455 "POST /session/deb05f0fcfaf8cfa21b8fc6b09d1a7af/window/rect HTTP/1.1" 200 0
DEBUG:selenium.webdriver.remote.remote_connection:Remote response: status=200 | data={"value":{"height":844,"width":1050,"x":0,"y":0}} | headers=HTTPHeaderDict({'Content-Length': '49', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:selenium.webdriver.remote.remote_connection:Finished Request
DEBUG:selenium.webdriver.remote.remote_connection:GET http://localhost:39455/session/deb05f0fcfaf8cfa21b8fc6b09d1a7af/window/rect {}
DEBUG:urllib3.connectionpool:http://localhost:39455 "GET /session/deb05f0fcfaf8cfa21b8fc6b09d1a7af/window/rect HTTP/1.1" 200 0
DEBUG:selenium.webdriver.remote.remote_connection:Remote response: status=200 | data={"value":{"height":844,"width":1050,"x":0,"y":0}} | headers=HTTPHeaderDict({'Content-Length': '49', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:selenium.webdriver.remote.remote_connection:Finished Request
{'width': 1050, 'height': 844}
@cgoldberg cgoldberg added A-needs-triaging A Selenium member will evaluate this soon! I-defect Something is not working as intended labels Apr 7, 2025
@selenium-ci
Copy link
Member

@cgoldberg, thank you for creating this issue. We will troubleshoot it as soon as we can.

Selenium Triage Team: remember to follow the Triage Guide

@cgoldberg cgoldberg changed the title [🐛 Bug]: [py] Can't set small window size with Chrome [🐛 Bug]: [py] Can't set small window size Apr 7, 2025
@shbenzer
Copy link
Contributor

shbenzer commented Apr 10, 2025

Good find - this is very likely an issue on the driver side. I like the idea of throwing an exception below a working threshold, but since it's an issue on their end, it'll possibly get fixed at some point, and we'll be left restricting the user, so I'll defer to TLC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-needs-triaging A Selenium member will evaluate this soon! C-py Python Bindings D-chrome I-defect Something is not working as intended OS-linux
Projects
None yet
Development

No branches or pull requests

3 participants