How to find XPath in Firefox Developer Edition?

Right-click on any element on the page. Select ‘Inspect Element’ in the pop-up menu. Right click on the tag in Inspector and select ‘Copy’ from pop-up & choose XPath. Paste the XPath wherever required.


$x(path, [startNode])

$x(path) returns an array of DOM elements that match the given XPath expression.

For example, the following returns all the <p> elements on the page:

 $x("//p")

browser javascript console

The following example returns all the <p> elements that contain <a> elements:

$x("//p[a]")

browser javascript console

Similar to the other selector functions, $x(path) has an optional second parameter, startNode, that specifies an element or Node from which to search for elements.

browser javascript console


Firstly there is no need of installing Add-ons in firefox developer edition, coz it's already packed with tools and all...

Now for Xpath:

Select any element by right click on it and choose Inspect Element(Q) then element/tag gets highlighted under inspector developer tool, (or you can open console by pressing F12 button).

Then Right Click on tag and select Copy=>Xpath, it will copy the Xpath of that element and then you can paste it on your script or notepad whatever you like..

Tags:

Xpath