-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Fix select being able to select options hidden by css rules #15135
base: trunk
Are you sure you want to change the base?
[py] Fix select being able to select options hidden by css rules #15135
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
…en if the argument text has spaces Fix error messages to be the same as java's one
User description
Description
This is my first time trying to contribute on open source!
I noticed some inconsistencies regarding the behaviour of select_by_visible_text() type of functions, if we look at java bindings:
selenium/java/src/org/openqa/selenium/support/ui/Select.java
Line 201 in 535f96f
we can see that selectByContainsVisibleText() checks if any css rule is hiding the option element before matching, while selectByVisibleText() does not:
selenium/java/src/org/openqa/selenium/support/ui/Select.java
Line 124 in 535f96f
I tried updating the python bindings and tests to match the java ones behaviour (raising NoSuchElementException on elements hidden by css rules), but I still haven't checked if other languages are the same or not.
I tried running tests on a Gitpod environment and they seem fine.
I think that the following things should be done:
● selectByVisibleText() in Select.java should also raise an exception on a hidden option
● maybe checking the other languages for the same kind of bug
● updating tests
Motivation and Context
Without this kind of check I think it ends up selecting options not visible to the user, rendering things like End to End tests a little bit more unreliable.
Types of changes
Checklist
PR Type
Bug fix, Tests
Description
Updated
select_by_visible_text
to raise exceptions for hidden options.Added
_has_css_property_and_visible
method to check CSS visibility.Enhanced tests to validate behavior with hidden options.
Ensured consistency with Java bindings for hidden option handling.
Changes walkthrough 📝
select.py
Add CSS visibility checks to selection methods
py/selenium/webdriver/support/select.py
_has_css_property_and_visible
method to check visibility.select_by_visible_text
anddeselect_by_visible_text
to raiseexceptions for hidden options.
visibility
,display
, andopacity
.select_class_tests.py
Add tests for hidden options in selection
py/test/selenium/webdriver/common/select_class_tests.py
invisibleMultiSelect
test data for hidden options.