Monday, June 23, 2008

Automate your test using Selenium IDE

Hi user,
I was started R & D on selenium open source tool few months back. and from that time I was continually trying my hands on this. And here is a good news. i have found some useful information and points which will really help you to implement this with in your project.
Recently in my current company, I have given demo on selenium IDE and Core. Here in this article I will point out about IDE. The core , I will cover later in my next article.

I am not not going to write here about basic of selenium. you can find all this here with http://selenium-ide.openqa.org. so I am starting with downloading and using. make sure the IDE is only can be use in Firefox.

Selenium IDE is a firefox plug in and can be install simply. For downloading this use http://selenium-ide.openqa.org/download.jsp. this will automatically install the IDE in your fireforx browser . Once downloaded with this IDE you can find it in tool menu bar.
Now point is this, how we can automate our test case using IDE.
So here I am taking an example:
Suppose you have to test the login module. so what are the possible test cases for this. some of them are:
1- Enter the correct user name and wrong password- result should be an error message " Invalid password"
2- Enter the wrong user name and correct password- result should be an error message " Invalid user name"
3- Enter the user name and leave the password field blank- result should be an error message "Password field can not be blank"
4- ..........
5..........
6............
.....
....
and the last one is enter both the fields with correct data. Login should success.

so what is the steps to automate these test cases. Suppose I want to automate the last test case. For this We need to record the steps and make the script. for this follow:
-> Open Firefox browser and then open Selenium from tool.
-> Now stop recording (make sure when selenium open first time it opens in record mode) by clicking the record button.
-> Now enter the url of your application.
-> Start recording by clicking start button again.
-> Now perform the steps (for login put the correct user name and put the correct password and then click on submit button now once you log in with application you need to verify your login). For this you need to use "VerifyText Present" function/method. For this you can select the login user name ( That is you expected result ) from top of the header and right click and select verify text present option.
-> Stop the recording. Now you have done with your first test . Here is the example I am giving , it is for login with rediffmail.com.


-> Now you need to save this test. You can save this anywhere using .html ext. Later you will need to make a test suit (to run multiple test at a time ). for this make a test suite and map all the test with in this suit. you need to create a folder and place all your test with in this folder. Your test suit will also be in this folder only.
-> Now run this test.
-> You will see the status of your test as passed in green color. For this you can play with testrunner screen. here is the test runner screen


Here you can see the result of your test. This is pass in this case.

So this is all about basic of how to record and run your test.
Now you can also edit your test and can be categorize using various methods/function available. So now you can implement this in your project as well.
If you have any question or suggestion, just drop a comment here or you can mail me at vishal.sachan@gmail.com

I appreciate your feed back,


references:
http://www.openqa.org/

9 comments :

  1. nice selenium by Mr. Vishal sachan .

    ReplyDelete
  2. Really Appreciable Vishal..keep it up.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Good job indeed. As a suggestion, I would say that organize the content of the post systematically to keep the interest of readers intact.
    Keep exploring the tool and posting your findings on it. Thanks.

    ReplyDelete
  5. Very gud Vishal
    I think it will be very useful for the fresher.
    You did a great job
    Keep it up.

    ReplyDelete
  6. hi all,
    i need to automate the text color whenever error message comes it displays in red color.
    can any one give the ans.

    thanks
    sanjay

    ReplyDelete
  7. Hi Vishal,the information given by u regarding Selenium IDE & test Runner is very useful..I request it will be helpful for all if u could give more information regarding Selenium RC & how the same test suite can run using selenium RC .

    ReplyDelete
  8. Really nice blog!!
    It is quite unique way to describe selenium test and seleniu tool. It is really good explanation for the beginner. If anyone want to lean more, he/she can visit Selenium Testing

    ReplyDelete