Alternative take on Selenium in Rails


#1

Hey there,

There’s been a bit of work going on with Selenium and Rails recently, so
I thought I may as well share what I came up with. Check out my blog
post at http://blog.viney.net.nz/articles/2006/02/09/selenium-testing,
grab the plugin and give it a whirl (be sure to read the README!).

Basically, my approach was to make it possible to write Selenium tests
in the same way that unit and functional tests are written. So, you end
up with test classes such as:

class PersonSeleniumTest < Test::Unit::TestCase
selenium_test
fixtures :people, :households

def setup
  open '/person/view/1'
end

def test_add_new_person
  click           'add_new_person_link'
  assert_visible  'add_new_person'
  type            'new_person_first_name', 'Pixel'
  type            'new_person_last_name', 'the Cat'
  select          'new_person_gender', 'Male'
  type            'new_person_creation_source', 'The Planet Zorg'
  click_and_wait  'submit_add_new_person', 4
  assert_contains 'person_name', 'Pixel the Cat'
end

end

This will be turned into a Selenium test suite when you run:

rake selenium

Anyway, enough for the forum. Check out the plugin if you’re interested.
It’s still quite rough, but it Works For Me.

  • Jonny.

#2

Jonathan V. wrote:

Check out my blog post at
http://blog.viney.net.nz/articles/2006/02/09/selenium-testing,
grab the plugin and give it a whirl (be sure to read the README!).

Sorry, the link got stuffed up. It should be
http://blog.viney.net.nz/articles/2006/02/09/selenium-testing

  • Jonny.