Skip to content
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

[🐛 Bug]: "Near" relative locator doesn't work for the dotNet #13610

Closed
mpushnikA1QA opened this issue Feb 20, 2024 · 5 comments · Fixed by #14737
Closed

[🐛 Bug]: "Near" relative locator doesn't work for the dotNet #13610

mpushnikA1QA opened this issue Feb 20, 2024 · 5 comments · Fixed by #14737
Labels
C-dotnet help wanted Issues looking for contributions I-defect support Issue or PR related to support classes

Comments

@mpushnikA1QA
Copy link

mpushnikA1QA commented Feb 20, 2024

What happened?

I came across the fact that the Near relative locator for dotNet does not work.
I tried to debag, and found that I did not have the element. I get null at this point - js.ExecuteScript(wrappedAtom, parameters);
https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/RelativeBy.cs#L109

Message: 
System.NullReferenceException : Object reference not set to an instance of an object.

There are no tests for near relative locators in the dotNet project - https://github.com/SeleniumHQ/selenium/blob/b6b209602d544b769a0f4635022cf55a7b8f81b4/dotnet/test/common/RelativeLocatorTest.cs

At the same time, test coverage looks better for Java - https://github.com/SeleniumHQ/selenium/blob/trunk/java/test/org/openqa/selenium/support/locators/RelativeLocatorTest.java

How can we reproduce the issue?

I tried using the web page https://github.com/SeleniumHQ/selenium/blob/trunk/common/src/web/relative_locators.html
 to test relative locators and add a test for the Near locator (By analogy with Java tests): 

[Test]
public void ShouldBeAbleToFindElementsNear()
{
 var elements = seleniumDriver.FindElements(RelativeBy
                            .WithLocator(By.TagName("td"))
                            .Near(By.Id("center")));

 Assert.That(elements, Is.EquivalentTo(new List<string> { "second", "eighth", "fourth", "sixth", "first", "third", "seventh", "ninth" }));"seventh", "ninth");
}

the elements variable is null.

Relevant log output

Message: 
System.ArgumentException : Expected: IEnumerable But was: null (Parameter 'actual')

Operating System

Windows 10

Selenium version

.Net

What are the browser(s) and version(s) where you see this issue?

Chrome

What are the browser driver(s) and version(s) where you see this issue?

chromedriverVersion, 121.0.6167.184

Are you using Selenium Grid?

No

Copy link

@mpushnikA1QA, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@titusfortner titusfortner added the support Issue or PR related to support classes label Mar 8, 2024
@titusfortner
Copy link
Member

we are not currently prioritizing work in the support packages.

@diemol diemol added help wanted Issues looking for contributions and removed needs-triaging labels Jul 12, 2024
Copy link

This issue is looking for contributors.

Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.

@RenderMichael
Copy link
Contributor

RenderMichael commented Nov 10, 2024

I figured out the problem - when we get back no elements the response will be [], and the de-serializer will not know we are getting back elements. As such, the as ReadOnlyCollection<IWebElement> will not work because the actual runtime type will be ReadOnlyCollection<object>.

Edit: Turns out that fixed a general deserializer problem, but Near still didn't work. I updated the PR to make it work.

Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-dotnet help wanted Issues looking for contributions I-defect support Issue or PR related to support classes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants