Class: SpecialSauce::Driver
- Inherits:
-
Object
- Object
- SpecialSauce::Driver
- Defined in:
- lib/special_sauce/driver.rb
Class Method Summary collapse
- .auth? ⇒ Boolean
- .authentication ⇒ Object
-
.browsers ⇒ Object
Set SAUCE_ONDEMAND_BROWSERS when running against multiple saucelabs browers.
- .current_browser_caps ⇒ Object
- .desired_capabilities(options = {}) ⇒ Object
-
.sanitized_browser_options(current_browser_id) ⇒ Object
Jenkins plugin doesn’t set browserName sometimes.
- .sauce_endpoint ⇒ Object
-
.single_browser_caps ⇒ Object
ENV vars for when running against a single saucelabs browser.
Class Method Details
.auth? ⇒ Boolean
6 7 8 |
# File 'lib/special_sauce/driver.rb', line 6 def auth? authentication != ':' end |
.authentication ⇒ Object
10 11 12 |
# File 'lib/special_sauce/driver.rb', line 10 def authentication "#{ ENV['SAUCE_USER_NAME'] }:#{ ENV['SAUCE_API_KEY'] }" end |
.browsers ⇒ Object
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_caps ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/special_sauce/driver.rb', line 51 def current_browser_caps if ENV['CURRENT_BROWSER_ID'] (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( = {}) [:plus_caps] ||= {} [:using_caps] || current_browser_caps.merge([: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 (current_browser_id) = browsers[current_browser_id] ['browserName'] ||= ['browser'] end |
.sauce_endpoint ⇒ Object
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_caps ⇒ Object
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' }
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 |