Tuesday, April 28, 2009

Selenium


Selenium Introduction.

Selenium is a open source ( Free !!! ) tool for function/regression, unit testing the web application. It has a IDE which is actually a firefox add-ons which lets you record/playback the events and it also lets you export your test cases into the other desired ( Java, php, .net, ruby ) language for further editing.

It has three main component provided by selenium and other optional provided by third party.
  1. Selenium IDE: Require to record/playback the testcase and to export it in other language
  2. Selenium Core: Central control
  3. Selenium RC: Allows you to run your test cases from any other languages on other browsers (like IE, Opera ) and on other platforms ( Mac, Windows )
  4. Junit/Nunit: Junit is framework if you choose java to write the testcases and Nunit is if you choose to write down the testcases in .Net
  5. ANT: This is the reporting tool.
The first three of the above are main components others are optional but essential.

Installation:
Now to install and setup the selenium is bit tedious task. You need to download the following things:
Now as you have downloaded the above things, you need to install/extract them to use
  • Selenium IDE will be installed automatically if you have use firefox to download it else a .xpi file would have been downloaded. Just drad and drop the file on the firefox and it will be installed.
  • Extract the Selenium Core, Selenium RC and Junit in your desired directory.
  • install the JDK
Now after this you need to set the path and classpath environment variables.
  • Find the out the "selenium-java-client-driver.jar" from the Selenium RC folder and set its full path as classpath as below
    set path=%classpath%;full path of ""selenium-java-client-driver.jar"
  • Find out the Junit-4.6jar ( file name may differ depends on the version you have downloaded) and set it full path in the classpath variable.
  • Find out the bin located inside the Java folder and set its path in the path variable.
Now you are ready to use the selenium with Java. But before we use it with Java we will see how to record and playback the testcases using selenium IDE


Record and playback using Selenium IDE:



Open the Firefox and open the Selenium IDE from the tool menu. Make sure the record (red button ) is pressed
  • Now you can start recording. Navigate to the Google.com and in the search box enter "Selenium IDE" or any other text. Now click on the first text present. Now go back to the IDE you will find the recorded steps in there.
  • You need to change all the "click" command with "clickandWait". and now you can playback to see whether the recorded test cases passes or not. Just click on the green arrow button and the testcase will be loaded in browser and will be executed.

7 comments:

Unknown said...

Hey Gaurang!

I have done all the steps mentioned above but I can not see JAVA RC in file>export Test cases>.
I can see , Junit RC, JAVA TestNG and other options, but not Java.

Have i missed any step.
Pls help

Thanks
Prit

Unknown said...

Hi Pritm,
No you are right. With newer version of selenium IDE they provides the facility to export Testcase in JAVA (TestNG) or Java (Junit).

Khel015 said...

Hi guarang!

I really find your blogs very useful to me. since im starting using selelium for testing test cases. i just want to ask if there is any better reporting tool that can be use with selenium IDE?

Thanks in advance,
Khel

Unknown said...

Hi Khel,
I don't know if there is any reporting tool for selenium IDE. But if you are planning to upgrade to selenium rc you can use TesNG which provides good results, you can also user ReportNG which is a extension of TestNG which gives somewhat more improved results.

Khel015 said...

Guarang,

now i install selenium RC on my machine. and i find it useful. what do i need for me to use a TestNG or reportNG. if you dont mind i just want to ask for your ym? is it ok. hehe.

Thanks in advance,
Khel

Unknown said...

Check out the other posts on TestNG in this blog. You will fine it useful.

Unknown said...

Hi Gaurang,
Could you please explain the step where you set the full classpath for selenium java client driver. Where do we need to make this setting?
can the selenium be run without any IDE like bromine, eclipse, testng.

I plan to use python for scripting the tests. I have followed all the steps till the initiating the selenium server. How do i proceed thereafter?

Regards..
Neeraj

Post a Comment