Selenium testing: Get your XPath right with the help of Firebug

Creating Selenium tests you often will find yourself fiddling around with (hopefully not too complex) XPaths. If you are having Firebug installed you can use one of its lesser known features to speed up working with XPaths.

Little example ?

Open up Firebug for this page, select the Console tab and enter the following command into the Firebug command line:
$x(“/html/body/div[2]/div/h1”)
Result:
[h1]
Note: Hover the mouse over the h1 and you will see the corresponding element highlighted in the page.

Even better – to have a look at the inner HTML of the headline element enter:
$x(“/html/body/div[2]/div/h1”)[0].innerHTML

This entry was posted in Misc and tagged , . Bookmark the permalink.

1 Response to Selenium testing: Get your XPath right with the help of Firebug

  1. Pingback: Selenium Locator Tips « JodieM.com.au

Leave a comment