Fix #4223: Restrict suppressNotFoundErrors to NoSuchElementError #4294
+186
−2
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
);