[java] Refactored selectByContainsVisibleText and selectByVisibleText methods to remove code duplication#16246
[java] Refactored selectByContainsVisibleText and selectByVisibleText methods to remove code duplication#16246vicky-iv wants to merge 7 commits intoSeleniumHQ:trunkfrom
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:
|
||||||||||||||
…HQ#16247) Co-authored-by: Selenium CI Bot <selenium-ci@users.noreply.github.com>
… methods to remove code duplication
|
Accidentally created from a wrong branch |
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 existingselectByVisibleTextandselectByContainsVisibleTextmethods.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
Extracted common logic into private
selectByVisibleTextmethodAdded boolean parameter to toggle partial/exact matching
Eliminated duplicate code between two selection methods
Preserved existing public interface and behavior
Diagram Walkthrough
File Walkthrough
Select.java
Refactor text selection methods to eliminate duplicationjava/src/org/openqa/selenium/support/ui/Select.java
selectByVisibleTextandselectByContainsVisibleTextmethodsmatching