[rspec-users] UI testing framework? (w/o selenium)

Bob Cotton bob.cotton at rallydev.com
Wed May 9 08:05:14 EDT 2007

"Tim Tischler" <tischler at purplecoffeecup.com> writes:

> Hey all,
> I am currently working on coming up w/ an easy to use, developer-centric
> web testing framework to test a J2EE app with. (I have 3 rails apps in
> production, love rspec, and am currently at a java shop).
> I've looked at selenium, and it just doesn't seem like it is ready for
> prime time, and the target audience is developers.   So, having said that,
> does the rspec community want a "functional" test framework?  Are you
> happy w/ selenium, and is it working?

We have re-written our functional test framework 4 times, and finally
settled on Selenium. No other open-source tool gets you the
cross-browser, cross-platform support.

We use the Ruby bindings for Selenium-RC.

> Unless someone convinces me of selenium, I'm planning on taking the basics
> and concepts of rspec, and focus it more towards testing web applications,
> and am happy to contribute.  My company is totally cool with contributing
> to open source projects if it makes sense.

Rspec sits at the core of our acceptance testing process. At the
beginning of an iteration, we define our acceptance tests using rspec
and product skeleton behaviors:

describe "this part of the system, in these conditions" do
  it "should behave like this"


> Any thoughts or suggestions?  Here is a sketch of what I think I'd
> like:
> server " http://localhost:8080" do
>   test '/' do
>  page.status.should_be "200"
>  page.should_have :image, "logo.gif"
>  page.should_have :string, "Copyright 2006-Present SomeCo, Inc. All
> rights reserved."
>  page.should_have :div, :id => 'copyright'


To me, this framework is "talking" at the wrong level of
abstraction. The domain of its "language" has to do with the
underlying technology, in this case HTML. 

Tests written at this level will be brittle and hard to maintain as
the application changes.

Our approach has been to build a framework that models our application
and provides a language in the domain of that application, i.e. it
uses the nouns and verbs of our application to provide an API for
testing the app. 

It is in essence a Domain Specific Language for testing our

For example, when the user creates "things" in our app, they use an
"Editor", and abstraction of an HTML form. The editor framework allows
you to write code that looks like this:

    user_page.click_create do |editor|
      editor.first_name = "John"
      editor.last_name = "Smith"

click_create handles the saving of the form (i.e. clicking save) for

The Editor class might look something like this:

    class UserEditor
      element_accessor :first_name, element_locator("first_name")
      element_accessor :last_name, element_locator("last_name")

where 'element_writer' and 'element_locator' are wrappers 
dealing with input fields in Selenium.

Then you can check the values in the form:

    editor.first_name.should == "John"

Now your tests don't talk about HTML. 


More information about the rspec-users mailing list