-
Notifications
You must be signed in to change notification settings - Fork 242
Using Selenium WebDriver
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.
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
require 'selenium-webdriver'
# If you want to delegate the driver management to the webdrivers gem, you also need to require it here
# require 'webdrivers' # or 'webdrivers/chromedriver' to be more specific
Teaspoon.configure do |config|
config.driver = :selenium
# config.driver_options = {client_driver: :firefox}
#
# or if you install off master
# `gem 'teaspoon', git:'https://github.com/jejacks0n/teaspoon.git', branch:master`
# you can get support for chrome headless
#
# config.driver_options = {
# client_driver: :chrome,
# selenium_options: {
# options: Selenium::WebDriver::Chrome::Options.new(args: ['headless', 'disable-gpu'])
# }
# }
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
.
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"