First steps with FirePath : What a useful tool

Continuing with the Automation project, WebDriver allows to interact with the DOM (Document Object Model) through XPath . Xpath provides a quite interesting approach to query the DOM, but sometimes it requires dedication and practice to fully understand how it works  and how the queries can be performed.

Since I need to interact with the DOM elements very often and WebDriver also provides a way to use XPath, then it is time to getting started using it.

I’ve been using Firebug for a while and I found a very interesting and helpful add-on called FirePath.

FirePath gives you the  XPath expression to locate the element, look for example how easy is to find an element in google :

ScreenHunter_148 Jan. 26 10.14

Let’s suppose I would like to find the dive where the country is displayed, then the XPath expression would be

ScreenHunter_147 Jan. 26 10.14

This is another approach to interact with XPath.

Advertisements

About Michael Hidalgo

Michael is a Software Developer Engineer based on San José, Costa Rica. He leads the OWASP Chapter from Costa Rica. You can take a look at my blog at http://blog.michaelhidalgo.info/
This entry was posted in Browser Automation, GUI, Selenium WebDriver, UnitTests and tagged . Bookmark the permalink.

2 Responses to First steps with FirePath : What a useful tool

  1. Dinis Cruz says:

    Well, it is even easier if you use jQuery 🙂

    which is why I usually start my O2 automation scripts with

    ie.injectJQuery() ; // if it is not already there

    which means that we can code similar XPATH query using the powerful jQuery selectors.

    Also see https://github.com/o2platform/O2.Platform.Scripts/tree/master/APIs/_Javascript_Libraries/JQuery

  2. Pingback: Best approach to find nested elements with WebDriver :When Xpath becomes your best friend | TeamMentor Development and Testing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s