Pages

Sunday, May 19, 2013

Master Selenium: Selenium IDE - Part-I




In a previous article "Pick your Test Automation Tool" i talked about the best approach a test automation engineer should follow to pick a tool that covers all his testing needs.

Selenium is one of the test automation tools on the market; free, easy to use and has the potential to live up to all your testing expectations.
With a set of 4 tools (Selenium IDE, Selenium RC, Selenium WebDriver and Selenium Grid) the power web automation giant makes it easy for an automation tester to record scripts, debug, playback and many other features that will make your job easier.

In this article we will see the basics of Selenium IDE, most importantly how to record scripts with Selenium IDE.

What is Selenium IDE?

Selenium IDE is a Firefox extension that allows recording, editing and debugging tests.
To get started, you have to download and install Selenium IDE: http://seleniumhq.org/download/

Record a test with Selenium IDE.

Start Selenium IDE (Web Developer → Selenium IDE or by clicking the launch button).
The following window should appear:
Selenium IDE main window





















After starting, Selenium IDE will already be in the recording mode (red button is pressed, previous picture). Now you can begin writing your first test:

1- Browse to «google.com»
2- Enter «Hello, World!» in the search
3- Click «I'm Feeling Lucky» button

After performing the steps described above, click on the red round button to stop test recording.
In the Selenium IDE we should observe the following picture:
Selenium script recorded





















Our first test is ready! Yoooooopiiiiiiii!!


Running the Test

Let's run the recorded test. To do this, click on the «Play current test case» button.
Play recorded test script




If everything is OK, the following sequence of actions should be repeated:
1. Google.com should be opened.
2. The text «Hello, World!» should be entered into the search. 
3. «I'm Feeling Lucky» button should be pressed

If something goes wrong, try to restart or rewrite the test!


Using Assert and Verify commands

Why use Assert and Verify commands?
They tell us that the test is passed as required, and there were no mistakes during the test.
What is the difference between Assert and Verify commands?
Verify commands simply check finding the item on the page, and Assert commands also stop the test, if the item was not found on the page

How to use these commands?
Right-click on any element on the page. After that the menu should appear:
Selenium IDE commands




















This menu allows us to use different variations of Assert and Verify commands. Use the command verifyTextPresent by simply clicking on the necessary menu item. Then the following line should
appear in the Selenium IDE:

Add a command in Selenium IDE











Debug test

Recording tests can go wrong and as a result we don't get what we need.
For such cases, the Selenium IDE includes some debugging tools:
The test can be paused (button «Pause»)
Then it can be done step by step (button «Step»)
Debug Selenium IDE






What I think About it!


Now I recommend you to subscribe to receive the upcoming posts about all related Quality Assurance subjects. The next article "Master Selenium: Selenium IDE - Part-II" will be posted soon.






No comments:

Post a Comment