-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
[py] Add detailed error message if KeyError thrown in get_window_size and get_window_position (#15503) #15504
base: trunk
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Unfortunately no. Because in the current context, it is not relevant at all. We do not need the exact values, we are not testing mathematics or calculations here. From the testing point of view: a = 100
assert a == 100 is a bicycle of trying to test the Python itself. The real testing starts when you try to use random data, while you already know what are your min and max values or data types. |
432cc99
to
92d9528
Compare
I don't see the point of using random data here. You are mocking the function and setting a return value. What's the advantage of having it change every time you run the test? |
I do not see any advantage in using the hardcoded value. In real-world window size and position may vary up to the max screen resolution known today - 16k. |
Please remove the randomization, as it serves no purpose. I will not merge code that adds complexity for no benefit. |
… and get_window_position (SeleniumHQ#15503)
92d9528
to
9564bde
Compare
Removed only as it became a requirement for merging, but not agree with reviewer |
@aikfiend |
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Motivation and Context
It returns a more detailed error than KeyError 'width' for a better understanding on which side is the error, the webdriver itself or the remote web server. Unfortunately, the build system is too complicated to do a simple fix and I do not agree and do not want to run all the existing tests as the changes made do not affect the other tests. Here I belong to your CI
Types of changes
Checklist
PR Type
Bug fix, Tests
Description
Added detailed error messages for
KeyError
inget_window_size
andget_window_position
.Enhanced error handling to clarify missing keys in window size and position.
Introduced new tests to validate error handling for missing keys.
Used mocking and parameterized tests to ensure robustness.
Changes walkthrough 📝
webdriver.py
Add detailed error handling for `KeyError` in window methods
py/selenium/webdriver/remote/webdriver.py
try-except
blocks to handleKeyError
inget_window_size
andget_window_position
.window_tests.py
Add tests for missing keys in window methods
py/test/selenium/webdriver/common/window_tests.py
get_window_size
andget_window_position
.get_window_rect
.KeyError
exceptions.