Go to the First name tab and right click >> Inspect. On inspecting the web element, it will show an input tag and attributes like class and id. Use the id and these attributes to construct XPath which, in turn, will locate the first name field.
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 answer
Here 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.
FirePath
panelYou can open the DevTools in Chrome with CTRL+I on Windows (or CMD+I Mac), and Firefox with F12, then select the Console
tab), and check the XPath by typing $x("your_xpath_here")
.
This will return an array of matched values. If it is empty, you know there is no match on the page.
By using Chrome or Opera
without any plugins, without writing any single XPath syntax character
;)
Another option to check your xpath is to use selenium IDE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With