1

Why Devtool cannot even find its own Xpath?

Windows 10, Latest Chrome Version 104.0.5112.102 (Official Build) (64-bit).

Clicked plus sign for a new tab. New tab went to default google search.

Please see screenshot enter image description here

  1. right clicked on the search field, selected Inspect. This opened DevTool, and highlighted the element.
  2. right clicked on the highlighted element, select Copy, XPath.
  3. Control + F in Devtool, pasted the Xpath into the search box.
  4. there was no match: 0 of 0 !!!

It was not a highlighting issue as some other posts reported.

oldpride
  • 761
  • 7
  • 15
  • 1
    Sounds like a bug. Apparently it doesn't work inside Shadow DOM. FWIW `id("input")` is a better xpath. – wOxxOm Aug 31 '22 at 05:48
  • Were namespaces involved? In XPath 1.0 paths to namespaced elements will usually involve a namespace prefix that has to be declared before the path can be executed. – Michael Kay Aug 31 '22 at 07:57
  • @wOxxOm, I think you are right. It must be Shadow DOM. When I posted the question, I wasn't aware of this new feature. After your hint, I read more articles. I believe it is due to Shadow DOM. Thank you – oldpride Aug 31 '22 at 20:21

1 Answers1

0

@wOxxOm suggested it was due to the tag was in a Shadow DOM. When I posted the question, I wasn't aware of this new feature. After his/her hint, I read more articles. I believe it is due to Shadow DOM.

enter image description here

I present this as a temporary answer, and leave for more knowledgeable folks to provide an acceptable answer.

There are good resources on Stack Overflow about Shadow DOM, for example this one does-anybody-know-how-to-identify-shadow-dom-web-elements-using-selenium-webdriv

oldpride
  • 761
  • 7
  • 15