Why Selenium and Rspec?


A year ago, I was put to the task, with the help of Joe Ocampo (fellow los techie) to have automated UI tests that everyone in a Development/QA environment (all levels of experience) can help with.  We wanted to have a framework/DSL that had the following objectives:

  1. Main Objective – Team Involvement (again all levels of experience in Development/QA Environment to assist in test creation)
  2. Readability
  3. Maintainable
  4. Scalable
  5. Tests suitable for Agile environment w/ ability to be executed through a CI Server

Based on prior experience using commercial UI automated tools, some of these principles we based on flaws of those tools, so we wanted to go the open source route, and the obvious choice was selenium.  At the time I had some experience writing selenium tests in python, plus I did create a selenium multi-thread runner in python by simply modifying unit-test library in python to accept threads. I was committed to using selenium just for solving the scalable objective (by utilizing selenium-grid).  This still didn’t solve the main objective of having Team Involvement.  This is were Joe had the vision of having me look into using of Rspec.  With the combination of Selenium and Rspec, we were able to solve all the objectives.

Team Involvement

With Rspec, manual testers could now participate in writing specs (which could replace the need to writing manual tests, because it is the manual test)

Manual testers could still write tests as you would in any manual testing tool (Action – Expected Result)

Example of pending spec (Manual test):


Using the power of Rspec; testers can easily write tests in this format. Once a spec has been written, trained QA testers will then ‘fill in’ the
test with automation test. This gives QA a more agile approach as far as keep the manual and
automation test together in one file.  The spec gives QA the opportunity to run the automated tests manually if
failure occurs.

Example of automated spec:


With the framework/DSL created and using Rspec assertions, it even allows the automation code to be easily read and reduces the need to know selenium api commands.  Selenium and Rspec have their own Selenium Test Formatter that will print out beautiful reports, that can be read by anyone in the
business, print screenshots, and capture selenium server logs in event of test

Example of passing test:


Specs will be written in a QA test repository (centralized), which will allow the reuse of code from other projects or applications automated.  (Object-Oriented Approach) objects and element classes will be
centralized and only maintained in one place, to make updates easier to

Example of object classes:


Utilizing Selenium Grid and multiple Selenium Servers, specs can be run on
multiple threads to decrease the amount of time to run the spec.

Tests suitable for Agile environment w/ ability to be executed through a
CI Server

Using this format manual specs can be written before development begins and automation can be filled in during and/or completion of development.  Writing Rake tasks to execute tests and using Hudson CI Server, selenium-grid plugin, and rake plugin, tests can easlly run and tracked. 

More to come!




About Scott Gillenwater

Hello everyone, I'm Scott Gillenwater. - I have a Bachelor's Degree in Information Systems - 10+ years of Experience that has ranged from software support to development with an expertise in Software Quality Assurance as a Senior Automation Engineer - Development experience primarily in Ruby, Python, Java, and JavaScript (Extjs) Languages - Developed a Framework/DSL around selenium using Ruby and Rspec that makes automation testing easier, and more maintainable. - Automation Tools of choice include: -- Selenium (Ruby or Python bindings), Selenium Grid (software web GUI functional/regression testing) -- Apache Jmeter (performance testing)
This entry was posted in automate, hudson, rspec, selenium. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

5 Responses to Why Selenium and Rspec?

  1. John Sonmez says:

    Very cool. I am doing something very similar with Watij and building a internal DSL as well as a full DSL on top of it.


    I had the same goals as you. I think it is really important for the success of automated function tests in agile, to make sure that just about anyone can write and understand the tests.

    I also think it is a very good idea to have developers initially create the framework.

    One thing I would like to do, is to be able to have an IDE with auto-complete that works for the DSL. Have you tried this yet?

  2. BjartN says:

    Looks great. I’m currently about to do something similar using a combination of Cucumber, Cuke4Nuke and WatiN.

    I like the idea of having multiple levels of abstraction on top of the selenium test code. It adds more value to the executable specifications when you can express them in a form that makes sense to non-coders

    Have your seen any problems with your approach ? Or is everything running smoothly ?

  3. John,
    I have actually had success using Net Beans IDE 6.8 with auto-complete working, and with ability to start stop rake tasks (selenium-grid, rc, mult-threaded tasks.)

  4. BjartN,
    Format works great, approach could be done the traditional way (all selenium test code wrapped in one it statement) or multiple it statements. Your right, multiple levels allows non codes/developers to participate more easily.

  5. Naoya Makino says:

    Hi Scott, thank you for this post. I have been working on selenium with rspec for while now and trying to put that in Hudson CI Server.
    would you be interested in expanding last section: “Tests suitable for Agile environment w/ ability to be executed through a CI Server”?
    I would very appreciate if you could explain that in detail.
    thank you,