Wednesday, February 24, 2010

Import Selenium cases from Selenium IDE to Selenium RC in Java

In this blog I will talk about how to import selenium cases from Selenium IDE to Selenium RC in Java
Before proceeding you need to do following things:
  1. Download Selenium Ide for firefox and add it to firefox.
  2. Download the Selenium RC distribution zip.
  3. Download Junit-4.5.jar
  4. Basic knowledge of Java is necessary.

Now I will start step by step on how to start writing selenium cases.
  1. Open Firefox . Start the selenium IDE by going to Tools → Selenium IDE.
  2. By default the recording feature of selenium IDE will be started. This can be identified by checking the Red circular icon on the right hand side of the window. If not clicking on the icon will start the recording.
  3. Now record your test by opening a web page and doing some action over it. For ex.
    1. Type “Selenium” in the search page.
    2. Click on “Search” button.
    3. Now click on the “Selenium Web application testing system”.
  1. Now go to the Selenium IDE window and stop the recording by clicking on the Red circular icon on the Right side of the window.
  2. Now your test is recorded. To verify your test you can re-run your recorded test by clicking onto the Play icon on the selenium window.
  3. Once your recording is verified. Click on Options → Format → Java(JUnit)-SeleniumRC. This will convert your recorded test into the Java -Junit format.
  4. Now install any Java IDE you want to use and create a new Java Project. I used Eclipse for developing my cases.
  5. After creation of new project , create a new Java class under the project. Now copy the Java-JUnit code from the Selenium IDE and paste it to this new Java class.
  6. Change the class name from the Selenium Ide to the Java Class file name that you created inside your project.
  7. Now add to the build path of the Java Project in Eclipse IDE "selenium-java-client-driver.jar" from the Selenium-java-client-driver folder under the Selenium RC distribution that you had downloaded. Also add "Junit-4.5.jar" to the build path.
  8. To Verify your Selenium RC set-up in Eclipse IDE you have to start the Selenium RC server first. This you can do by going to the Selenium-server folder under the Selenium RC distribution that you had downloaded using the command prompt and running the command “java -jar selenium-server.jar”
  9. Once the server is started Verify your test case by going to the Eclipse IDE and running the test-case as a Junit case.
  10. Once your test case is executed properly your Selenium-RC setup is ready.
  11. You can write your custom code over it and do whatever actions you want to do.
  12. In the similar way you record your Test-cases through Selenium IDE and bring it to Selenium RC for modifications.


Godwin said...

HI Friend,

In my web application, there are pages with both HTTP & HTTPS.
I'm working with Selenium RC 1.0.1 , Firefox 3.5.9 and Selenium IDE 1.0.2.
I have recorded the scripts in firefox(3.5.9) and i could run the same scripts in IE 8(both HTTP & HTTPS).
But, I'm facing a prolem in Safari and Google Chrome.That is, script gets struck up in HTTPS page and thus the result says there is no such field or value in the page.
How do i make my script to run in HTTPS page too.
Waiting for your help.

magnifictraining said...
This comment has been removed by a blog administrator.
Varun Menon said...

@magnifictraining - Appreciate your feedback, but please do not post links and advertise in my blog.


Post a Comment