Chrisrod's Weblog

febrero 21, 2010

Creating a Selenium RC test case in 7 simple steps

Filed under: Selenium Test — chrisrod @ 7:40 pm

In this little tutorial I will explain as clear as I can, how to create a test case using Selenium IDE, Selenium RC and JUnit, hope it will be useful for everybody.

01.   Download Selenium RC and after downloading Selenium IDE ( install it in Firefox


Figure 01. Download page of Selenium IDE and RC.


02.   Open Selenium IDE in firefox, look for my blog in google and click on the first link that appears:


Figure 02. Selenium IDE on firefox.


03.   Export the test case to JUnit clicking on Options à Format àjava JUnit

04.   Personally, I don’t want just to copy and paste the code that is just autogenerated  by Selenium IDE, you can do this, but it is more fun to create some classes and subclasses and then make run your test cases J. So you can check at the code that I generated from the help that I got from Selenium IDE.

package com.selenium.test;


import com.thoughtworks.selenium.SeleneseTestCase;




 * Abstract class that will setUp() and tearDown() all the test classes that

 * will extend this class.


 * @author Christian Roman



abstract class SeleniumTestBase extends SeleneseTestCase {


       * Method that will open the web browser and redirect it to the main page of

       * google.



      public void setUp() throws Exception {

            setUp(«», «*chrome»);





       * Method that will close the session opened by the method setUp().



      public void tearDown() throws Exception {





      public void clickGoogleLink(String keyword, String link){

            selenium.type(«q», keyword);








Listing 01.

 package com.selenium.test;


import org.junit.Test;


public class GoogleSearchTest extends SeleniumTestBase {



      public void testChrisrodWordpress() throws Exception {


            clickGoogleLink(«chrisrod wordpress», «SEAM « Chrisrod’s Weblog»);


                        .isTextPresent(«Uso del LDAP para el modulo de autenticaciones en SEAM»));




      public void testHowToDraw() throws Exception {

            clickGoogleLink(«how to draw faces», «Portrait Drawing – Learn to Draw Faces»);

            assertTrue(selenium.isTextPresent(«Learn portrait drawing skills including face proportions»));



Listing 02.

05.   The structure of my code looks like this:

Figure 03. Code structure for running the test cases and libraries needed to accomplish this objective.


06.   Run selenium server, I mean double click over the jar file: selenium-server.jar, that comes with Selenium RC.

07.   Run your JUnit test case and enjoy watching how your web browser open, executes commands and close by itself (well actually controlled by Selenium Server)


Figure 04. Running JUnit on GoogleSearchTest.


Figure 05. Selenium Server in action.

11 comentarios »

  1. Hi, i think that i saw you visited my site thus i came
    to “return the favor”.I am attempting to find things to improve my site!
    I suppose its ok to use some of your ideas!

    Comentario por Selena — septiembre 18, 2012 @ 9:41 am | Responder

  2. Excellent read, I just passed this onto a friend who was doing a little research on that.
    And he just bought me lunch because I found it for him smile Therefore let me rephrase that: Thanks
    for lunch!

    Comentario por Amee — septiembre 19, 2012 @ 11:28 pm | Responder

  3. Hey there, I think your blog might be having browser compatibility issues.

    When I look at your blog in Safari, it looks fine but
    when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other then
    that, excellent blog!

    Comentario por Cary — septiembre 22, 2012 @ 3:04 am | Responder

  4. My brother suggested I might like this blog. He was entirely right.
    This post truly made my day. You can not imagine simply how much time I had spent for this
    info! Thanks!

    Comentario por Quyen — septiembre 24, 2012 @ 10:51 pm | Responder

  5. Hey I know this is off topic but I was wondering if you knew of any
    widgets I could add to my blog that automatically tweet my newest twitter
    updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

    Comentario por Valencia — septiembre 29, 2012 @ 8:42 am | Responder

  6. Magnificent goods from you, man. I’ve bear in mind your stuff previous to and you’re just extremely magnificent.

    I really like what you’ve bought here, certainly like what you are saying and the way during which you assert it. You are making it enjoyable and you still take care of to keep it wise. I can not wait to learn much more from you. That is really a great web site.

    Comentario por Sharon — octubre 6, 2012 @ 11:39 am | Responder

  7. Hey there! This is kind of off topic but I need some guidance from
    an established blog. Is it very hard to set up your own blog?
    I’m not very techincal but I can figure things out pretty fast. I’m thinking about
    setting up my own but I’m not sure where to start. Do you have any tips or suggestions? Thank you

    Comentario por Sergio — octubre 7, 2012 @ 6:18 am | Responder

  8. Thanks for the tips about credit repair on
    this site. What I would offer as advice to people is always to give up a mentality that they can buy right now and shell out later.

    As a society most people tend to do that for many factors.
    This includes vacation trips, furniture, in addition to items we wish.

    However, you’ll want to separate your current wants from all the needs. While you are working to raise your credit score you really have to make some trade-offs. For example you’ll be able to shop online to save
    cash or you can go to second hand suppliers instead of highly-priced department stores regarding clothing.

    Comentario por Anderson — octubre 11, 2012 @ 3:25 am | Responder

  9. Hey There. I found your blog using msn. That is a very neatly written article.
    I will make sure to bookmark it and return to learn extra
    of your useful information. Thank you for the post.

    I’ll definitely return.

    Comentario por Tiffiny — octubre 12, 2012 @ 7:54 pm | Responder

  10. Aw, this was a very nice post. In idea I want to put in writing like this moreover
    – taking time and actual effort to make an excellent article… however what can I
    say… I procrastinate alot and under no circumstances
    seem to get something done.

    Comentario por Willa — octubre 14, 2012 @ 6:45 am | Responder

  11. Everything is very open with a very clear explanation of
    the issues. It was truly informative. Your website is extremely helpful.
    Many thanks for sharing!

    Comentario por myagkaya Mebel — octubre 22, 2012 @ 12:01 pm | Responder

RSS feed for comments on this post. TrackBack URI

Deja una respuesta

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Salir /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Salir /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s

Blog de

A %d blogueros les gusta esto: