Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find xpath of an element in firefox inspector

Tags:

firefox

xpath

In Firefox 50.1, Firebug is no longer available so I have to use the inspector but I cannot find copy ---> xpath option that was available in Firebug. How can I find the xpath of an element using the inspector?

like image 298
papakias Avatar asked Jan 25 '17 17:01

papakias


People also ask

How do I find the XPath of an element?

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.

How do I get absolute XPath in Firefox?

Firefox browser (v72): Right-click webpage -> Inspect Element -> Right-click on web element -> Copy -> XPath (If the web element has any unique id then it will give you the relative XPath otherwise it will give absolute XPath).

How can I get XPath in Firefox without firebug?

Press F12, this opens the developer tools. Then click anywhere in the HTML structure and press Ctrl + F or Cmd + F if you're on a Mac. In the search bar that appears you can search by XPath, Css selectors or strings. So if you type //div/div/form for example, you can immediately check if the XPath works.


2 Answers

You can use the console to check if the xpath you want return the correct element or not. $x("//div/xpath") https://developer.mozilla.org/en-US/docs/Tools/Settings

like image 92
mosaad Avatar answered Sep 23 '22 14:09

mosaad


Follow Bellow Steps:

Step 1 : Right click on page -> Select (Inspect Element)

Step 2 : Pick an element from the page

Step 3 : Right Click on highlighted html -> Copy -> Xpath

enter image description here

like image 40
Nanhe Kumar Avatar answered Sep 23 '22 14:09

Nanhe Kumar