Skip to content
milaniliev edited this page Sep 12, 2010 · 15 revisions

Webrat has Selenium support through Webrat::Selenium (see the Webrat::Selenium RDoc).

Using Selenium through Webrat is surprisingly easy:

  sudo gem install webrat
  sudo gem install selenium-client

Configure Webrat (in your test/test_helper.rb, or in env.rb):


require “webrat”

Webrat.configure do |config|
config.mode = :selenium

  1. optional:
    config.application_port = 4567 # defaults to 3001. Avoid Selenium’s default port, 4444
    config.application_framework = :sinatra # could also be :merb. Defaults to :rails
    end

Then, run your favorite Webrat integration test, something like:

class SignupTest < ActionController::IntegrationTest

    def test_trial_account_sign_up
      visit home_path
      click_link "Sign up"
      fill_in "Email", :with => "good@example.com"
      select "Free account"
      click_button "Register"
    end

  end
Clone this wiki locally