How to get the XPath of an element from Firefox inspector?
15,994
Solution 1
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
Cu.import("resource:///modules/sessionstore/XPathGenerator.jsm");
XPathGenerator.generate(content.document.querySelector("unique selector placeholder"));
Paste the unique selector then form the Execute menu select Display
Solution 2
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:
Related videos on Youtube
Comments
-
Superbest almost 2 years
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?
-
NewSites almost 7 yearsThanks 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.