Class: SpecialSauce::Driver

Inherits:
Object
  • Object
show all
Defined in:
lib/special_sauce/driver.rb

Direct Known Subclasses

Capybara, Watir

Class Method Summary collapse

Class Method Details

.auth?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/special_sauce/driver.rb', line 6

def auth?
  authentication != ':'
end

.authenticationObject



10
11
12
# File 'lib/special_sauce/driver.rb', line 10

def authentication
  "#{ ENV['SAUCE_USER_NAME'] }:#{ ENV['SAUCE_API_KEY'] }"
end

.browsersObject

Set SAUCE_ONDEMAND_BROWSERS when running against multiple saucelabs browers. The value should be a JSON serialized array of browser capabilities. (Set by jenkins plugin.)



35
36
37
38
39
40
41
42
# File 'lib/special_sauce/driver.rb', line 35

def browsers
  all_browser_caps = ENV['SAUCE_ONDEMAND_BROWSERS'] && JSON.parse(ENV['SAUCE_ONDEMAND_BROWSERS'])
  if all_browser_caps && all_browser_caps.size > 0
    all_browser_caps
  else
    [single_browser_caps]
  end
end

.current_browser_capsObject



51
52
53
54
55
56
57
# File 'lib/special_sauce/driver.rb', line 51

def current_browser_caps
  if ENV['CURRENT_BROWSER_ID']
    sanitized_browser_options(ENV['CURRENT_BROWSER_ID'].to_i)
  else
    single_browser_caps
  end
end

.desired_capabilities(options = {}) ⇒ Object



59
60
61
62
# File 'lib/special_sauce/driver.rb', line 59

def desired_capabilities(options = {})
  options[:plus_caps] ||= {}
  options[:using_caps] || current_browser_caps.merge(options[:plus_caps])
end

.sanitized_browser_options(current_browser_id) ⇒ Object

Jenkins plugin doesn’t set browserName sometimes.



45
46
47
48
49
# File 'lib/special_sauce/driver.rb', line 45

def sanitized_browser_options(current_browser_id)
  options = browsers[current_browser_id]
  options['browserName'] ||= options['browser']
  options
end

.sauce_endpointObject



14
15
16
# File 'lib/special_sauce/driver.rb', line 14

def sauce_endpoint
  "http://#{ authentication }@ondemand.saucelabs.com:80/wd/hub"
end

.single_browser_capsObject

ENV vars for when running against a single saucelabs browser. (As set by jenkins plugin.)

Example running locally against saucelabs: { ‘browserName’ => ‘internet explorer’,

'version' => '9',
'platform' => 'Windows 7' }

github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities



26
27
28
29
30
# File 'lib/special_sauce/driver.rb', line 26

def single_browser_caps
  { 'browserName' => ENV['SELENIUM_BROWSER'],
    'version' => ENV['SELENIUM_VERSION'],
    'platform' => ENV['SELENIUM_PLATFORM'] }
end