special_sauce makes it easy to run existing capybara or watir based (selenium) tests against Sauce Labs browsers.
gem 'special_sauce', '0.2.0'
If the authentication ENV variables are set, special_sauce
will try to set up a remote browser, otherwise default to chrome.
@browser = SpecialSauce::Watir.browser || Watir::Browser.new(:chrome)
If the authentication ENV variables are set, special_sauce
will try to set up a remote browser and set the current drivers, otherwise use Chrome locally.
Capybara.register_driver :selenium_chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
SpecialSauce::Capybara.setup_session || Capybara.current_driver = :selenium_chrome
special_sauce
relies on the following env vars to set up remote sessions with sauce labs.
You can set these explicitly or rely on the Sauce OnDemand Plugin to set them in Jenkins builds.
Authentication Variables - Required
Environment Variable | Value |
---|---|
SAUCE_USER_NAME | your saucelabs username |
SAUCE_API_KEY | saucelabs api key for your username |
When calling SpecialSauce::Watir.browser
or SpecialSauce::Capybara.setup_session
without any arguments, special_sauce
will use env vars to determine browser capabilities.
You may set these explicitly or rely on the Sauce OnDemand Plugin to set them for you.
It is recommended you explicitly declare your browser capabilities with using_caps
.
To override default browser capabilities, use using_caps
:
custom_caps = { 'browserName' => 'internet explorer',
'version' => '9',
'platform' => 'Windows 7' }
@browser = SpecialSauce::Watir.browser(using_caps: custom_caps)
To add additional browser capabilities, use plus_caps
:
additional_caps = { 'tunnel-identifier' => ENV['TRAVIS_JOB_NUMBER'] }
SpecialSauce::Capybara.setup_session(plus_caps: additional_caps)
See Sauce Lab's Documentation for more options such as test name, build number, and screen resolution.
additional_caps = { 'name' => 'my test name', 'screenResolution' => '1280x1024' }
@browser = SpecialSauce::Watir.browser(plus_caps: additional_caps)
The gem is available as open source under the terms of the MIT License.
- Appraise more versions of ruby & versions of capybara & watir.
- Allow customization of ENV variables?
- Add 'contributing' section.