Using jQuery Selectors to interact with TeamMentor : A good starting point for browser automation

It’s important to take advantage of the cutting-edge technologies we are using at TeamMentor and make sure those technologies can be used to perform testing and improve the quality of the product. 

Since at TeamMentor we rely on jQuery, it’s important to understand what a jQuery selector is and why are they useful and important. As decribed in the jQuery official page: “…jQuery offers a powerful set of tools for matching a set of elements in a document.”

As an example, if you would like to locate all the  HTML heading 1 in a page, then the jQuery selector could be something like this : jQuery(“h1”).html(“Hello!”);  or just $(“h1”).html(“Hello!”);.

A complete list of jQuery selectors can be found here  , here and here.

Using jQuery Selector in TeamMentor via Firefox

Using firebug, this task is very easy, you will need to open firebug and then select the Console tab. At the bottom there should be  a console window to enter some commands:

Image

 

 

 

Now, let’s use the following selector to put some  html on all the HTML heading 2: $(“h2”).html(“Hello TeamMentor!!”);

Selectors

Look that after executing that command, all the h2 heading elements in the page constrains now the text “Hello TeamMentor!!”

From this stand point, we can use the power of jQuery selectors to locate elements in the DOM and make easy the  testing.

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 Uncategorized and tagged , , . Bookmark the permalink.

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