Using Selenium WebDriver

Mike Pack edited this page Apr 21, 2015 · 13 revisions

Teaspoon allows using Selenium when running specs from the rake task or command line interface. This allows you to test on a broader spectrum of browsers, but is slower and is a little more complex to setup on CI.

This page is dedicated to how to get setup and running.

Setup

You'll need to include the selenium-webdriver gem in your Gemfile.

gem "selenium-webdriver"

Configure Teaspoon to use the selenium driver. You can also pass some options along to Selenium using the driver_options directive.

spec/javascripts/teaspoon_env.rb

Teaspoon.configure do |config|
  config.driver = :selenium
  # config.driver_options = {client_driver: :firefox}
end

Now when you run rake teaspoon it should be using Firefox to run your specs. You can also override the driver using rake teaspoon DRIVER=selenium or bundle exec teaspoon --driver=selenium.

Travis CI

To get this running on Travis CI, you'll need to add a .travis.yml file that contains the following:

.travis.yml

before_script:
  - 'sh -e /etc/init.d/xvfb start'
env:
  - DISPLAY=":99.0"