-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix #4223: Restrict suppressNotFoundErrors to NoSuchElementError #4294
Merged
garg3133
merged 4 commits into
nightwatchjs:main
from
Vaibhavsahu2810:issue/4223-fix-suppress-error
Nov 27, 2024
Merged
Fix #4223: Restrict suppressNotFoundErrors to NoSuchElementError #4294
garg3133
merged 4 commits into
nightwatchjs:main
from
Vaibhavsahu2810:issue/4223-fix-suppress-error
Nov 27, 2024
Conversation
This file contains 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
garg3133
reviewed
Nov 18, 2024
@garg3133 is this okay now, I have made all the changes that are needed |
garg3133
reviewed
Nov 22, 2024
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.
@Vaibhavsahu2810 Yes, it does look good now.
Status
|
Merged after adding a few tests, thanks @Vaibhavsahu2810! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This pull request addresses issue #4223. The suppressNotFoundErrors property in the new Element API previously suppressed all errors encountered by the WebDriver, including errors like InvalidSelectorError. This behavior was unintended, as suppressNotFoundErrors should ideally only suppress NoSuchElementError.
Changes Made
Updated scoped-element.js to catch and handle NoSuchElementError specifically when suppressNotFoundErrors is enabled.
Modified the logic to allow other errors, like InvalidSelectorError, to propagate as expected.
Steps to Reproduce the Issue
Use an invalid selector in a test command:
await browser.element.find({
selector: '@something',
suppressNotFoundErrors: true
});
Observe that InvalidSelectorError is no longer suppressed and propagates as intended.
Proof of Work
Terminal Output
The attached screenshot shows the updated terminal output, where an InvalidSelectorError is correctly thrown when an invalid selector is provided.
Unit Test
A unit test was added to ecosia.js to validate this behavior. The test checks that an invalid selector throws InvalidSelectorError instead of suppressing it.
Thanks in advance for your contribution. Please follow the below steps in submitting a pull request, as it will help us with reviewing it quicker.
examples/tests
directory of the project) and running them.ecosia.js
andduckDuckGo.js
are good examples to work with.features/my-new-feature
orissue/123-my-bugfix
);