You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Description
selectVisibleByText was implemented differently than other language bindings of Selenium. It did not account for text with spaces. The changes made here fix that.
Motivation and Context
Ensure language parity regarding this particular feature.
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
3, because the PR involves changes across multiple files including core functionality, utility functions, and tests. The logic for handling quotes and string manipulations is non-trivial and requires careful review to ensure correctness and efficiency.
🧪 Relevant tests
Yes
🔍 Possible issues
Possible Bug: The implementation assumes that the multiple attribute's value can only be 'false' or null when not set. However, according to HTML standards, any non-empty string including 'false' should be treated as true. This could lead to incorrect behavior in isMultiple() method.
Performance Concern: The method selectByVisibleText could be inefficient for large select lists as it potentially iterates through all options multiple times to match text values, especially when fallback logic is triggered.
🔒 Security concerns
No
✨ Review tool usage guide:
Overview:
The review tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be added by configuring the tool.
The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:
Add error handling for promise rejection in getAttribute method.
Consider handling the promise rejection in the getAttribute method to avoid unhandled promise rejections, which can lead to application crashes or unexpected behavior. Use a try-catch block to handle potential errors.
Optimize finding the longest substring without space using reduce.
Optimize the getLongestSubstringWithoutSpace function by using built-in JavaScript methods to find the longest word, reducing the complexity of the function.
-let words = text.split(' ')-let longestString = ''-for (let word of words) {- if (word.length > longestString.length) {- longestString = word- }-}+const longestString = text.split(' ').reduce((longest, word) => word.length > longest.length ? word : longest, '');
Add early exit for no options found in selectByVisibleText to enhance performance.
Ensure that the selectByVisibleText method handles cases where no options are found before proceeding to check for spaces in the text, which can prevent unnecessary processing.
Use const for unmodified variables to enhance code safety.
Use const for variables that are not reassigned to ensure they cannot be accidentally changed elsewhere in the code, enhancing code safety and clarity.
Overview:
The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.
When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Description
selectVisibleByTextwas implemented differently than other language bindings of Selenium. It did not account for text with spaces. The changes made here fix that.Motivation and Context
Ensure language parity regarding this particular feature.
Types of changes
Checklist
Type
Enhancement, Bug fix
Description
selectByVisibleTextinselect.jsto handle text with spaces and special characters more accurately.escapeQuotesandgetLongestSubstringWithoutSpaceto aid in XPath query generation.select_test.jsto ensure the robustness of the updatedselectByVisibleTextmethod.select_space.htmlto facilitate testing of the new selection capabilities.Changes walkthrough
select.js
Enhance selectByVisibleText and Support Special Charactersjavascript/node/selenium-webdriver/lib/select.js
constructor.
selectByVisibleTextto handle options with spaces and specialcharacters more robustly.
escapeQuotesandgetLongestSubstringWithoutSpacehelperfunctions.
isMultiplemethod to use a cached value of the multipleattribute.
fileserver.js
Add New Test Page for Select Elementjavascript/node/selenium-webdriver/lib/test/fileserver.js
testing.
select_space.html
New HTML Test Page for Select Elementcommon/src/web/select_space.html
functionality.
select_test.js
Extend Tests for New selectByVisibleText Logicjavascript/node/selenium-webdriver/test/select_test.js
escapeQuotesfunction handling different quotescenarios.