How can I verify my XPath?
I am using Chrome Developers tool to inspect the elements and form my XPath. I verify it using the Chrome plugin XPath Checker, however it does not always give me the result. What is a better way to verify my XPath.
I have also tried using Firebug to inspect the bug and also using the FirePath to verify. But does Firepath also verify the XPath.
My last option would be to use the Selenium WebDriver to confirm my XPath.
This can be achieved by three different approaches (see my blog article here for more details):
Elements
panel like below$x()
and $$()
in Console
panel, as shown in Lawrence's answerHere is how you search XPath in Elements
panel:
Since FF 75 it's possible to use raw xpath query without evaluation xpath expressions, see documentation for more info.
In the command line at the bottom use the following:
$()
: Returns the first element that matches. Equivalent to document.querySelector()
or calls the $
function in the page, if it exists.
$$()
: Returns an array of DOM nodes that match. This is like for document.querySelectorAll()
, but returns an array instead of a NodeList
.
$x()
: Evaluates an XPath expression and returns an array of matching nodes.