-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[java] Refactored selectByContainsVisibleText and selectByVisibleText methods to remove code duplication #16257
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
[java] Refactored selectByContainsVisibleText and selectByVisibleText methods to remove code duplication #16257
Conversation
… methods to remove code duplication
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Thank you, @vicky-iv for this code suggestion. The support packages contain example code that many users find helpful, but they do not necessarily represent After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. |
PR Code Suggestions ✨Explore these optional code suggestions:
|
That's weird.. CI failed with an HTTP 403 trying to download a package from npm. I just kicked it off again. |
@cgoldberg Looks like only the Ruby tests are failing now, and they're not related to the changes in this PR. Is there anything else I need to do to get this merged? |
@vicky-iv yea, CI looks good. I'll ping the Slack channel to see if someone more familiar with the Java bindings can give it a final review. I usually only merge Python stuff :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally OK, but have a suggestion. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
User description
🔗 Related Issues
[🚀 Feature]: Unifying Select Class Across All Bindings #15265
💥 What does this PR do?
This is a tiny addition to my previous PR #16220
Refactored selectByContainsVisibleText and selectByVisibleText methods to remove code duplication
🔧 Implementation Notes
This change was inspired by the current .NET implementation, where there is only one method for both cases, using a boolean switch to toggle between partial and exact matches.
I preserved the existing Java interface (and existing implementation of both methods) by extracting the common selection logic into a new private method
selectByVisibleText(String text, boolean isPartialMatch)
, and reused it across the existingselectByVisibleText
andselectByContainsVisibleText
methods.All tests from the following packages are passed locally:
//java/test/org/openqa/selenium/support/ui/...
💡 Additional Considerations
--
🔄 Types of changes
PR Type
Other
Description
Refactored
selectByVisibleText
andselectByContainsVisibleText
methodsExtracted common logic into private method with boolean parameter
Eliminated code duplication while preserving existing interface
Improved maintainability by consolidating selection logic
Diagram Walkthrough
File Walkthrough
Select.java
Refactor text selection methods to eliminate duplication
java/src/org/openqa/selenium/support/ui/Select.java
selectByVisibleText
andselectByContainsVisibleText
methodsisPartialMatch
boolean parameter