Saucelabs Integration

Setting up Saucalabs for browser testing is easy, and will save you a ton of hassle from  maintaining  Selenium Grid. Once you get a SauceLabs account, you can just plug in to your test setup. You can create a module to include the browsers you want to test. Here’s an example of sauce module with the desired capabilities.

module Sauce

  def browser(type)

    case type

      when :safari
        caps = Selenium::WebDriver::Remote::Capabilities.safari
        caps['platform'] = 'OS X 10.11'
        caps['version'] = '9.0'

      when :ff, :firefox, :Firefox
        caps = Selenium::WebDriver::Remote::Capabilities.firefox
        caps.platform = "Windows 8"
        caps.version = '34'

      when :chrome, :Chrome
        caps = Selenium::WebDriver::Remote::Capabilities.chrome
        caps["chromedriverVersion"] = "2.20"
        caps['platform'] = 'Windows 10'
        caps['version'] = '46.0'
    end

    caps["video-upload-on-pass"]= false
    caps["record-screenshots"]= false
    caps['record-logs'] = false
    caps["capture-html"]= false
    caps["max-duration"]= 180
    caps["public"]= "team"
    caps["seleniumVersion"]= "2.48.2"

    @driver = Selenium::WebDriver.for(
        :remote,
        :url => "http://{username}:{sauce_api_key}@ondemand.saucelabs.com:80/wd/hub",
        :desired_capabilities => caps)

  end
end