-
-
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
[dotnet] Fix RelativeBy.Near
and empty list return, port Java tests
#14737
[dotnet] Fix RelativeBy.Near
and empty list return, port Java tests
#14737
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
RelativeBy.Near
, port Java tests
RelativeBy.Near
, port Java testsRelativeBy.Near
and empty list return, port Java tests
Tests are a one-to-one clone of the java tests: https://github.com/SeleniumHQ/selenium/blob/trunk/java/test/org/openqa/selenium/support/locators/RelativeLocatorTest.java With the exception of the one C#-deserializer-specific test at the bottom |
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
Bug 1:
The
Near
method is now fixed, with a "blind" copy of what the Java code is doing.Bug 2:
When querying for elements using the relative locator, sometimes you are returned nothing. In that case, the response JSON is
[]
, and the de-serializer doesn't know you're getting back web elements.As such, the response object has a runtime type of
ReadOnlyCollection<object>
and the castas ReadOnlyCollection<IWebElement>
fails (ie, returns null).I can't think of a more elegant solution that doesn't require gutting the JavaScript execution process.
One more reason the
as
operator is not the right tool when the type is expected to be an exact match 🫠Motivation and Context
Fixes #13610
Types of changes
Checklist
PR Type
Bug fix, Tests
Description
Changes walkthrough 📝
RelativeBy.cs
Handle empty results in relative locators
dotnet/src/webdriver/RelativeBy.cs
elements are found.
RelativeLocatorTest.cs
Add test for empty result in relative locators
dotnet/test/common/RelativeLocatorTest.cs
relative locators.