class SpecialSauce::Driver
Public Class Methods
auth?()
click to toggle source
# File lib/special_sauce/driver.rb, line 6 def auth? authentication != ':' end
authentication()
click to toggle source
# File lib/special_sauce/driver.rb, line 10 def authentication "#{ ENV['SAUCE_USER_NAME'] }:#{ ENV['SAUCE_API_KEY'] }" end
browsers()
click to toggle source
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.)
# 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_caps()
click to toggle source
# 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 = {})
click to toggle source
# 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)
click to toggle source
Jenkins plugin doesn't set browserName sometimes.
# 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_endpoint()
click to toggle source
# File lib/special_sauce/driver.rb, line 14 def sauce_endpoint "http://#{ authentication }@ondemand.saucelabs.com:80/wd/hub" end
single_browser_caps()
click to toggle source
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
# 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