class Sauce::Selenium2

Attributes

config[R]
driver[R]
raw_driver[R]
watir[R]

Public Class Methods

new(opts={}) click to toggle source
# File lib/sauce/selenium.rb, line 54
def initialize(opts={})
  @config = Sauce::Config.new(opts)
  http_client = ::Selenium::WebDriver::Remote::Http::Persistent.new
  http_client.timeout = 300 # Browser launch can take a while

  @driver = Sauce.webdriver_method.call(: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

  @watir = defined?(Watir::Browser) && @driver.is_a?(Watir::Browser)
  @raw_driver = watir ? @driver.driver : @driver

  raw_driver.file_detector = lambda do |args|
    file_path = args.first.to_s
    File.exist?(file_path) ? file_path : false
  end

  Sauce::Selenium2.used_at_least_once
end
used_at_least_once() click to toggle source
# File lib/sauce/selenium.rb, line 50
def self.used_at_least_once
  @used_at_least_once = true
end
used_at_least_once?() click to toggle source
# File lib/sauce/selenium.rb, line 46
def self.used_at_least_once?
  @used_at_least_once || false
end

Public Instance Methods

current_url() click to toggle source
# File lib/sauce/selenium.rb, line 84
def current_url
  raw_driver.current_url
end
method_missing(meth, *args) click to toggle source
# File lib/sauce/selenium.rb, line 76
def method_missing(meth, *args)
  @driver.send(meth, *args)
end
session_id() click to toggle source
# File lib/sauce/selenium.rb, line 80
def session_id
  raw_driver.send(:bridge).session_id
end
stop() click to toggle source
# File lib/sauce/selenium.rb, line 88
def stop
  @driver.quit
end