Selenium IDE is an integrated development environment for performing Selenium tests. Selenium tests can be written as HTML tables or coded in various languages like C#, PHP, Perl, Python and can be run directly in most modern browsers.The IDE can help you to record, edit and debug tests. Currently the IDE is only available for Firefox (as if we developers will use any other) as a addon.
Here is a possible scenario for using Selenium. Imagine you have created a HTML form with about twenty fields and you have to repeatedly test the form. Filling the form every time can quickly become tedious. With Selenium you can automate the whole process and run the test as required. In this part we will see how to create a simple test in Selenium. So let’s get started.
STEP 1 – installation :
You can download Selenium IDE from this locations.
Once the addon is installed make sure you do not forget to restart Firefox.
STEP 2 – running a simple test :
a. Start Selenium IDE in Firefox: Tools->Selenium IDE. You will see the following popup.
b. Click on the red record button on the right.
c. Browse to Google.com and enter ‘selenium’ in the search box and click enter.
d. Click on the first result, which is that of selenium.openqa.org.
e. Stop the recording by clicking on the record button.
You should see something like below. If you click on the ‘ Source’ tab you can see the test html generated by selenium.
The ‘table’ tab shows the commands recorded by Selenium.
f. Open a new tab in Firefox and click on the Selenium IDE’s play button to run the recorded test.
The IDE should play your recorded test. After the test is complete you should have landed on the selenium page (http://selenium.openqa.org/). The IDE after the test run is shown below. In the ‘Log section’ you can see the various events run by the test. In the table tab you can see that all the rows are green, which means that the test ran successfully.
Now lets add a small assertion to the above test.
a. Click on the blank line below after the last ‘clickAndWait’ command and insert ‘assertTextPresent’ command from the drop down box as shown below. You should see something like this.
This test checks to see if the text ‘Selenium News’ is present in the last rendered page. Run the test again and you should see that the test has run successfully. No try replacing the text with something that is not present on the page, take for example ‘elvis’ and run the test again. Now the test fails and you should get the screen below.
You have just completed your first test run. And it was so simple.
‘assertTextPresent’ is one of the hundreds of commands available for your testing needs. Just browse throught the command drop down to get a feel of what you can you get.
In the next part we will see more advanced features of Selenium.
This site is a digital habitat of Sameer, a freelance web developer working in PHP & MySQL.More