Using Firebug 2.0 to craft XPaths

Firebug has been my favorite Firefox add-on for a long time now. In the time before every browser had decent developer tools, Firebug was a revolutionary add-on that allowed many testers, like myself, tools to interact, learn and explore what web applications were doing. I recently upgraded my Firebug to version 2.0. I was pleasantly surprised to find a cool feature that I think testers will find useful – the ability to check XPATHs within Firebug. Thank you Firebug community!

In case you missed it, here is how you use this super-cool feature.

Setup for Firebug 2.0

1. Install/Upgrade-to the latest firefox browser from here. We used version 30.0 of Firefox for this post. Firefox 29.1 did not list Firebug 2.0 as an available add on.

2. Download and install the latest firebug add-on from here.
The firebug icon will appear on the right corner on the tool bar.
firebug-addon

3. Activate the firebug console by clicking the firebug icon. By default the firebug console will appear at the bottom. (This can be changed as per your preferences)
firebug_activated

Steps to craft your XPath using Firebug 2.0

Lets pretend we want to craft an XPath for the first headline link on my favorite chess website Chessbase.

1.Visit the url http://www.chessbase.com, right click on the top headline and choose to inspect element with Firegbug. You should see something like the screenshot below.

firebug_xpath_1

2. We cannot use the text of the link or the href itself since they change on a news site. Instead we look around for something more permanent. We notice that the link (the ‘a-tag’) is nested in a div whose class contains ‘featured_true’. So the XPath we want is

//div[contains(@class,'featured_true')]/descendant::a

We can test the validity of our XPath in Firebug like in screenshot below

Verify XPath with Firebug 2.0

NOTE: In the past I have used other good add-ons like XPather and XPath Checker to craft my XPaths.

PS: Anton Smirnov (born 2001!) becomes the first chess prodigy to make a guest appearance on our blog. See the second article on the Chessbase screenshot

Vrushali Toshniwal
My journey as a tester started at Sun Microsystems (now Oracle). I was part of the testing and sustaining team for the Portal Server and Identity Management products. My first assignment was to test the Rewriter module. I enjoyed understanding the big picture, writing test cases, finding bugs and sometimes suggesting the fix too! I was hooked onto testing. Testing felt natural and intuitive to me. I am technically inclined and can write automation in Java, C++, Perl and Python. I am well versed with SilkTest, Selenium, Appium and Selendroid. I am a Computer Science graduate from BITS-Pilani. I love travelling and listening to music.

© 2013-2017, Vrushali Toshniwal. All rights reserved.

Be First to Comment

Leave a Reply

Your email address will not be published.