Skip to content

[🐛 Bug]: Message KeyError 'width' while trying to get_window_size() does not provide detailed information #15503

@aikfiend

Description

@aikfiend

What happened?

Image
So from the user's point of view, it is not clear on which side the error is, the webdriver itself or the remote web server.

How can we reproduce the issue?

It is hard to reproduce, but the remote web server used for the remote webdriver should be unreliable and return an error, as shown in the screenshot. In my case, it was BrowserStack Automate.

As requested in the comment:
https://github.com/aikfiend/python-selenium-browserstack/tree/get-window-size-key-error

Please note that the code of the test provided does not reproduce the issue in 100% of cases, as the issue itself reproduces from time to time, depending on a remote web server. You may require hundreds or more retries.

In the period from 2025-03-11 to 2025-04-21, I was able to catch it 20 times running tests in 24/7 mode in Browserstack Automate. Commonly, it failed in Chrome and Safari on mobile devices.

Relevant log output

Let the sentry speak for itself

Operating System

Any

Selenium version

4.31.0 (trunk)

What are the browser(s) and version(s) where you see this issue?

Any

What are the browser driver(s) and version(s) where you see this issue?

Any

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions