-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[js]: Fix sendKeys command fail on FileDetector.handleFile error. #14663
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
cc: @harsha509 @pujagani |
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 @garg3133 !
Somehow got the tests working locally and without the change made in this PR, the added test failed with the below error (as expected): So, the added test is working correctly. cc: @AutomatedTester |
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
When using the
.sendKeys
command with a file detector, if the promise returned by thehandleFile
method of file detector results in a rejection, the control moves to the catch clause and then to the lastthis.execute_
function call.Now, the problem with this flow is that in case of the
handleFile
error, thekeys
variable remains anArray
as opposed to it being converted to a string ifhandleFile
runs without any error. But, the lastthis.execute_
function call expectskeys
to be a string.This results in
keys.split is not a function
error when the flow goes through thecatch()
clause.So, this PR fixes this issue by converting
keys
to string if the flow goes through thecatch
clause so that the lastthis.execute_
always receiveskeys
in a string format, as expected.Motivation and Context
One of the Nightwatch.js users is facing an issue due to this: nightwatchjs/nightwatch#4280. They are using a remote file detector (
new require('selenium-webdriver/remote').FileDetector()
) in their test and when they try to send a large block of text to a text input using the.sendKeys
command, they are getting thekeys.split is not a function
errorPlease check this comment for more detailed analysis. tl;dr: Sending long text using
.sendKeys
with the file detector enabled leads toENAMETOOLONG
error which is not handled by the remote file detector'shandleFile
method, causing the method to be rejected, due to which the control flow lands inside thecatch()
clause inwebdriver.js > sendKeys
withkeys
variable still anArray
, and using the.split
method on an Array leads to thekeys.split is not a function
error.Types of changes
Checklist
PR Type
Bug fix, Tests
Description
sendKeys
command where an error inhandleFile
would cause akeys.split is not a function
error by ensuringkeys
is converted to a string in the catch block.sendKeys
when the file detector'shandleFile
method rejects, ensuring robust error handling.Changes walkthrough 📝
webdriver.js
Fix `sendKeys` command to handle file detector errors correctly
javascript/node/selenium-webdriver/lib/webdriver.js
keys
to a string in the catch block.keys
is always a string before callingthis.execute_
.webdriver_test.js
Add test for `sendKeys` handling file detector errors
javascript/node/selenium-webdriver/test/lib/webdriver_test.js
sendKeys
with a file detector handlingerrors.
sendKeys
function behaves correctly whenhandleFile
rejects.