How to Find XPath on the latest versions Firefox (56+):

With the release of Firefox version 56+, Firepath & Firebug becomes legacy addons and no longer supported. We can no longer use this addons to construct the XPath.

For the latest of Firefox, all the capabilities of Firebug are now present in current Firefox Developer Tools. With the Developer Tool of Firefox, we can now easily identify the XPath.

 Assume we need to find the XPath of the Email or Phone text box of Facebook login page.

Right click on the field as shown below and click Inspect Element.

Once you clicked, it will open the inspector view as shown below and will highlight the html text box which is tag input.

Now right click on the html, it will display context menu with copy options. Click the XPath from the sub menu.

It will automatically construct the XPath as //*[@id=”email”]. You can directly copy & use this XPath in automation code.

Firefox constructs the XPath based on id, in case ID is generating dynamically we can’t use the XPath in our automation code.

If ID is not present as attribute for the html element, then it will generate the absolute XPath which can breakup in the long run.

How TruePath Help you Construct XPath

It creates the multiple XPath, for the target field email & Phone.

From the multiple option, that the TruePath generates, one can easily select the suitable one. Since it generates the relative XPath, the possibility of broken down of the XPath is low. Once selected, it will provide the format options to select from either in the normal or page object format.

For more details on TruePath click here
To check or construct XPath manually, one can click console of the developer tool of the Firefox browser as shown below

The most comprehensive Selenium WebDriver cheat sheet dedicated to the locators




label element


label element with @id= ‘Id’


label elements with @id not equal to ‘id’


input elements that have name attribute

//*[contains (@id, ‘Id’)]

element with @id containing

//*[starts-with(@id, ‘Id’)]

element with @id starting with

//*[ends-with(@id, ‘Id’)]

element with @id ending with

//*[matches(@id, ‘r’)]

element with @id matching regex ‘r’


image element with @name= ‘Name’

//*[@id=’X’ or @name=’X’]

element with @id X or a name X


element with @name N & specified @value ‘v’

//*[@name=”N” and @value=”v”]

element with @name N & specified @value ‘v’

//*[@name=”N” and not(@value=”v”)]

element with @name N & not specified @value ‘v’


input of type submit


returns <section> if it has an <h1> descendant with @id= ‘hi’

//table[count(tr) > 1]

return table with more than 1 row


element containing text ‘t’ exactly

//a[contains(text(), “Log Out”)]

anchor with inner text containing ‘Log Out’

​//a[not(contains(text(), “Log Out”))]

anchor with inner text not containing ‘Log Out’


anchor with target link ‘url’


first child of element img


first child ‘li’ of ‘ul’


first img child


last child of element img


last img child


second last img child


‘a’ following some sibling ‘input’



sibling element immediately following ‘a’

‘a’ preceding some sibling ‘input’


sibling element immediately preceding ‘input’


the parent of image with id


cell by row and column


cell immediately following cell containing ‘t’ exactly


cell immediately following cell containing ‘t’


checkbox (or radio button) that is checked


all ‘a’ elements that are disabled


all ‘a’ elements that are not disabled

//a[@price > 2.70]

‘a’ with price > 2.7


All the children of uL