Skip to content

[🐛 Bug]: [dotnet] ShadowRoot element searching does not use By's method #15335

Open
@RenderMichael

Description

@RenderMichael

What happened?

The By type has special handling in many cases for custom methods. We use it to make sure FindElements(By.Id("")) returns an empty list instead of throwing. Users can also override By.FindElementMethod and By.FindElementsMethod for custom implementations.

This has been applied to WebDriver and WebElement, but not to ShadowRoot. We can apply it there as well so By behaves consistently.

How can we reproduce the issue?

driver.Url = shadowRootPage;
IWebElement element = driver.FindElement(By.CssSelector("custom-checkbox-element"));
ISearchContext shadowRoot = element.GetShadowRoot();
Assert.That(shadowRoot.FindElements(By.Id("")), Is.Empty);

Relevant log output

N/A

Operating System

N/A

Selenium version

4.29

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

N/A

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

N/A

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!C-dotnet.NET BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions