Skip to content

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

Open
@cgoldberg

Description

@cgoldberg

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!C-pyPython BindingsD-chromeI-defectSomething is not working as intendedOS-linux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions