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]: Invalid locator - GetShadowRoot and By.Xpath #12123

Closed
jrod567 opened this issue May 31, 2023 · 6 comments
Closed

[🐛 Bug]: Invalid locator - GetShadowRoot and By.Xpath #12123

jrod567 opened this issue May 31, 2023 · 6 comments
Labels
G-chromedriver Requires fixes in ChromeDriver

Comments

@jrod567
Copy link

jrod567 commented May 31, 2023

What happened?

When working with the shadowdom, using the By.XPath locator strategy is throwing an invalid locator unexpectedly.

Using other locators works fine and this is only an issue when working with IWebElement.GetShadowRoot() searchcontext.

How can we reproduce the issue?

IWebElement host = _driver.JH_FindElement(By.CssSelector("div[id='someid']"));
ISearchContext shadowRoot = host.GetShadowRoot();
IReadOnlyCollection<IWebElement> results = shadowRoot.FindElements(By.XPath(".//input"));

Relevant log output

Message: 
OpenQA.Selenium.WebDriverArgumentException : invalid argument: invalid locator
  (Session info: chrome=113.0.5672.127)

  Stack Trace: 
WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
WebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters)
ShadowRoot.FindElements(By by)

Operating System

Windows 10

Selenium version

4.8.1, 4.9.1

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

Chrome v113.0.5672.127

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

Latest

Are you using Selenium Grid?

Yes, 4.9.1

@github-actions
Copy link

@jrod567, 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!

@diemol
Copy link
Member

diemol commented May 31, 2023

That error comes from Chrome directly, they need to support XPATH as well.

More context #11893. Please raise this with the Chrome/ChromeDriver team.

@diemol diemol added G-chromedriver Requires fixes in ChromeDriver and removed I-defect needs-triaging labels May 31, 2023
@github-actions
Copy link

Hi, @jrod567.
This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team.
Feel free to comment the issues that you raise back in this issue. Thank you.

@titusfortner
Copy link
Member

titusfortner commented May 31, 2023

Depending on your situation you might try:

shadowRoot.FindElement(By.CssSelector("*")).FindElements(By.XPath(".//input"))

@jrod567
Copy link
Author

jrod567 commented May 31, 2023

Thank you!! Titus - that's helpful, much appreciated!

Copy link

github-actions bot commented Dec 9, 2023

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

@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
G-chromedriver Requires fixes in ChromeDriver
Projects
None yet
Development

No branches or pull requests

3 participants