Sha256: b02948e7ff8b28c0971539852d8ea481be3694eb09812c530865045f2360dbfb

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

require "selenium/client"
require "selenium/webdriver"

module Sauce
  class Selenium < ::Selenium::Client::Driver
    def initialize(opts={})
      @config = Sauce::Config.new(opts)
      super(opts.merge({:host => @config.host, :port => @config.port,
           :browser => @config.to_browser_string, :url => @config.browser_url}))
    end

    def passed!
      self.set_context "sauce:job-result=passed"
    end

    def failed!
      self.set_context "sauce:job-result=failed"
    end
  end

  class Selenium2
    def initialize(opts={})
      @config = Sauce::Config.new(opts)
      http_client = ::Selenium::WebDriver::Remote::Http::Default.new
      http_client.timeout = 300 # Browser launch can take a while
      @driver = ::Selenium::WebDriver.for(:remote, :url => "http://#{@config.username}:#{@config.access_key}@#{@config.host}:#{@config.port}/wd/hub", :desired_capabilities => @config.to_desired_capabilities, :http_client => http_client)
      http_client.timeout = 90 # Once the browser is up, commands should time out reasonably
    end

    def method_missing(meth, *args)
      @driver.send(meth, *args)
    end

    def session_id
      @driver.send(:bridge).session_id
    end

    def stop
      @driver.quit
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sauce-1.0.2 lib/sauce/selenium.rb
sauce-1.0.1 lib/sauce/selenium.rb
sauce-1.0.0 lib/sauce/selenium.rb
sauce-0.20.0 lib/sauce/selenium.rb
sauce-0.19.1 lib/sauce/selenium.rb
sauce-0.19.0 lib/sauce/selenium.rb