Saucer

Convenience methods for running your Ruby tests on Sauce Labs

Disclaimer

This code is provided on an "AS-IS” basis without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement. Your tests and testing environments may require you to modify this framework. Issues regarding this framework should be submitted through GitHub. For questions regarding Sauce Labs integration, please see the Sauce Labs documentation at https://wiki.saucelabs.com/. This framework is not maintained by Sauce Labs Support.

Installation

Add this line to your application's Gemfile:

gem 'saucer'

Usage

Configuration

Can optionally pass in a Config::Selenium instance with any of the supported Test Configuration Options Note that Ruby syntax is a Symbol with snake_case and not String with camelCase

config_selenium = Config::Selenium.new(version: '53', browser_name: :firefox)
@driver = Driver.new(config_selenium)

Cucumber

RSpec doesn't need to be concerned with this, but Cucumber needs an extra step in env.rb:

Before do |scenario|
  Saucer::Config::Sauce.scenario = scenario
  @driver = Saucer::Driver.new
end

After do |scenario|
  Saucer::Config::Sauce.scenario = scenario
  @driver.quit
end

Parallel

The most basic usage for parallel execution is to define the following Rake task, which will every spec in the spec directory in 4 processes on the default Sauce platform (Linux with Chrome v48)

Saucer::Parallel.new.run

To Specify basic number of processes, a specific subdirectory (Cucumber or RSpec), and reporting output file:

Saucer::Parallel.new(number: 7,
                     path: 'features/foo',
                     output: 'foo').run

To specify Sauce configurations, create a Rake Task that takes parameters like this:

task :parallel_sauce do
  configs = [{os: :mac_10_10, browser: :chrome, browser_version: 38},
             {os: :mac_10_11, browser: :firefox, browser_version: 46},
             {os: :mac_10_8, browser: :chrome, browser_version: 42}]

  platforms = configs.map { |c| Saucer::PlatformConfiguration.new(c) }

  Saucer::Parallel.new(platforms: platforms).run
end

or you can use the default rake task and define your configurations in configs/platform_configs.yml like this:

  - :os: :mac_10_10
    :browser: :chrome
    :browser_version: 38
  - :os: :mac_10_11
    :browser: :firefox
    :browser_version: 46
  - :os: :mac_10_8
    :browser: :chrome
    :browser_version: 42

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/saucer.

License

The gem is available as open source under the terms of the MIT License.