Is it possible to get the XPath of an element with the Firefox "inspect element" function (Q)?

The Chrome inspector can do this, but if I use the "Copy Unique Selector" option with Firefox's inspector, I get a selector in a different format, not XPath.

I know there are extensions, but is it possible without extensions?


It is possible, but I doubt if anyone would try it more than a couple of times

Copy the unique selector

Open Scratchpad

Switch environment to browser

Paste the following snippet

XPathGenerator.generate(content.document.querySelector("unique selector placeholder"));

Paste the unique selector then form the Execute menu select Display

| improve this answer | |

I know this question is old, but this feature now exists in the Developer tools of Firefox Quantum.

After inspecting, you can right-click the tag and Copy->XPath:

enter image description here

| improve this answer | |

You can use Firebug extension on Firefox to get xpath expression. Chrome Inspector or firebug do not generate more accurate xpath which are based on attributes like Class, ID or related attributes, example below


So in that cause you can use some kind of xpath expression generator tools like http://webdata-scraping.com/xpath-generator/

Which has point and click user interface to generate different types of Xpaths.

| improve this answer | |
  • Thanks for that link to XPath Generator. It's frustrating that the descendant of FireBug doesn't support generation of XPaths in Firefox, so that tool is a helpful replacement for that functionality. – NewSites Aug 16 '17 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.