Skip to content Skip to sidebar Skip to footer

Xpath //* Vs //element Vs //

I have a confusion in finding XPath: When to put //* at start and when to put just // will work. For example, I was trying to clear this thing on https://www.myntra.com/. There is

Solution 1:

  1. //*[@class='desktop-searchBar']

    says to select all elements, regardless of name, with an class attribute value of desktop-searchBar.

  2. //input[@class='desktop-searchBar']

    says the same as #1 except constrains the element to be named input.

  3. //[@class='desktop-searchBar']

    is syntactically invalid in XPath because it's missing a required node test such as input (element named input) or * (any element).

Post a Comment for "Xpath //* Vs //element Vs //"