simple_sauce 0.1.0 → 1.0.0.pre.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +14 -1
- data/README.md +1 -1
- data/lib/simple_sauce/options.rb +118 -15
- data/lib/simple_sauce/session.rb +22 -25
- data/lib/simple_sauce/version.rb +1 -1
- data/simple_sauce.gemspec +1 -2
- data/spec/options.yml +56 -0
- data/spec/options_spec.rb +431 -38
- data/spec/session_spec.rb +59 -61
- metadata +20 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6cabcc9d048c033cb89c6eb328e364c7a1f047c202453c89f5685e84e2a91f8
|
4
|
+
data.tar.gz: cb3e8f3fcca010f06dfbb09a576b71e1ed90a92305adda8fac58138ba530d942
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e86505a7b8ad04a1e6e0f3627f1e94082be58e09a01ff035177fcfd60cebf85cd6610424ca7b257b8ef103750dbb32dae30973cb1c82a2feb20b05173c864af1
|
7
|
+
data.tar.gz: 962d17eaba87c010b65308ddce0e7ad9f9d336074d752a2be97e1482a2e9abbd7cf9cb62b2ca65dc518c55d6bd1223a5f0a0e599348e433ebf27ee43e16328f0
|
data/.rubocop.yml
CHANGED
@@ -8,15 +8,28 @@ require:
|
|
8
8
|
Layout/SpaceInsideHashLiteralBraces:
|
9
9
|
EnforcedStyle: no_space
|
10
10
|
|
11
|
+
Metrics/AbcSize:
|
12
|
+
Max: 22
|
13
|
+
|
11
14
|
Metrics/BlockLength:
|
12
15
|
Exclude:
|
13
16
|
- "**/*_spec.rb"
|
14
17
|
|
18
|
+
Metrics/CyclomaticComplexity:
|
19
|
+
Max: 7
|
20
|
+
|
21
|
+
Metrics/PerceivedComplexity:
|
22
|
+
Max: 8
|
23
|
+
|
24
|
+
Metrics/ClassLength:
|
25
|
+
Exclude:
|
26
|
+
- 'lib/simple_sauce/options.rb'
|
27
|
+
|
15
28
|
Metrics/LineLength:
|
16
29
|
Max: 120
|
17
30
|
|
18
31
|
Metrics/MethodLength:
|
19
|
-
Max:
|
32
|
+
Max: 16
|
20
33
|
|
21
34
|
Metrics/ModuleLength:
|
22
35
|
CountComments: false
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ sauce_options = SimpleSauce::Options.new(screen_resolution: '1080x720',
|
|
52
52
|
selenium_options = Selenium::WebDriver::Remote::Capabilities.new(accept_insecure_certs: false,
|
53
53
|
page_load_strategy: 'eager'}
|
54
54
|
|
55
|
-
browser_options = Selenium::WebDriver::Firefox::Options.new(args
|
55
|
+
browser_options = Selenium::WebDriver::Firefox::Options.new('args' => ['-foo'])
|
56
56
|
```
|
57
57
|
|
58
58
|
### Session class
|
data/lib/simple_sauce/options.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'selenium-webdriver'
|
4
|
+
|
3
5
|
module SimpleSauce
|
4
6
|
class Options
|
5
7
|
class << self
|
@@ -8,40 +10,116 @@ module SimpleSauce
|
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
11
|
-
|
13
|
+
BROWSER_NAMES = {Selenium::WebDriver::Chrome::Options => 'chrome',
|
14
|
+
Selenium::WebDriver::Edge::Options => 'MicrosoftEdge',
|
15
|
+
Selenium::WebDriver::Firefox::Options => 'firefox',
|
16
|
+
Selenium::WebDriver::IE::Options => 'internet explorer',
|
17
|
+
Selenium::WebDriver::Safari::Options => 'safari'}.freeze
|
12
18
|
|
13
|
-
|
14
|
-
|
15
|
-
firefox_profile_url idle_timeout iedriver_version max_duration name parent_tunnel passed prerun
|
16
|
-
prevent_requeue priority proxy_host public record_logs record_screenshots record_video
|
17
|
-
restricted_public_info screen_resolution selenium_version source tags time_zone tunnel_identifier
|
18
|
-
username video_upload_on_pass capture_performance].freeze
|
19
|
+
W3C = %i[browser_name browser_version platform_name accept_insecure_certs page_load_strategy proxy
|
20
|
+
set_window_rect timeouts unhandled_prompt_behavior strict_file_interactability].freeze
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
SAUCE = %i[avoid_proxy build chromedriver_version command_timeout custom_data extended_debugging idle_timeout
|
23
|
+
iedriver_version max_duration name parent_tunnel prerun priority public record_logs record_screenshots
|
24
|
+
record_video screen_resolution selenium_version tags time_zone tunnel_identifier video_upload_on_pass
|
25
|
+
capture_performance].freeze
|
24
26
|
|
27
|
+
attr_accessor :browser_name, :browser_version, :platform_name, :accept_insecure_certs, :page_load_strategy, :proxy,
|
28
|
+
:set_window_rect, :timeouts, :unhandled_prompt_behavior, :strict_file_interactability, :avoid_proxy,
|
29
|
+
:build, :chromedriver_version, :command_timeout, :custom_data, :extended_debugging, :idle_timeout,
|
30
|
+
:iedriver_version, :max_duration, :name, :parent_tunnel, :prerun, :priority, :public, :record_logs,
|
31
|
+
:record_screenshots, :record_video, :screen_resolution, :selenium_version, :tags, :time_zone,
|
32
|
+
:tunnel_identifier, :video_upload_on_pass, :capture_performance
|
33
|
+
attr_reader :selenium_options
|
34
|
+
|
35
|
+
def initialize(**opts)
|
36
|
+
parse_selenium_options(opts.delete(:selenium_options))
|
25
37
|
create_variables(SAUCE + W3C, opts)
|
38
|
+
@build ||= build_name
|
39
|
+
|
40
|
+
@browser_name ||= selenium_options['browserName'] || 'chrome'
|
41
|
+
@platform_name ||= 'Windows 10'
|
42
|
+
@browser_version ||= 'latest'
|
26
43
|
end
|
27
44
|
|
28
45
|
def capabilities
|
29
|
-
caps =
|
46
|
+
caps = selenium_options.dup
|
47
|
+
W3C.each do |key|
|
30
48
|
value = send(key)
|
31
|
-
|
49
|
+
key = self.class.camel_case(key)
|
50
|
+
value = parse_w3c_key(key, value)
|
51
|
+
caps[key] = value unless value.nil?
|
32
52
|
end
|
33
53
|
caps['sauce:options'] = {}
|
34
54
|
SAUCE.each do |key|
|
35
55
|
value = send(key)
|
36
|
-
|
56
|
+
key = self.class.camel_case(key)
|
57
|
+
value = parse_sauce_key(key, value)
|
58
|
+
caps['sauce:options'][key] = value unless value.nil?
|
37
59
|
end
|
38
60
|
caps
|
39
61
|
end
|
40
|
-
|
41
62
|
alias as_json capabilities
|
42
63
|
|
64
|
+
def add_capabilities(opts)
|
65
|
+
opts.each do |key, value|
|
66
|
+
raise ArgumentError, "#{key} is not a valid parameter for Options class" unless respond_to?("#{key}=")
|
67
|
+
|
68
|
+
if value.is_a?(Hash)
|
69
|
+
value = value.each_with_object({}) do |(old_key, val), updated|
|
70
|
+
updated[old_key.to_sym] = val
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
send("#{key}=", value)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
43
78
|
private
|
44
79
|
|
80
|
+
def parse_w3c_key(key, value)
|
81
|
+
if key == 'proxy' && value
|
82
|
+
value.as_json
|
83
|
+
elsif key == 'timeouts' && value
|
84
|
+
value.each_with_object({}) do |(old_key, val), updated|
|
85
|
+
updated[self.class.camel_case(old_key)] = val
|
86
|
+
end
|
87
|
+
else
|
88
|
+
value
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def parse_sauce_key(key, value)
|
93
|
+
if key == 'prerun' && value.is_a?(Hash)
|
94
|
+
value.each_with_object({}) do |(old_key, val), updated|
|
95
|
+
updated[self.class.camel_case(old_key)] = val
|
96
|
+
end
|
97
|
+
elsif key == 'customData' && value.is_a?(Hash)
|
98
|
+
value.each_with_object({}) do |(old_key, val), updated|
|
99
|
+
updated[self.class.camel_case(old_key)] = val
|
100
|
+
end
|
101
|
+
else
|
102
|
+
value
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def parse_selenium_options(selenium_opts)
|
107
|
+
opts = Array(selenium_opts)
|
108
|
+
|
109
|
+
opts.each do |opt|
|
110
|
+
browser = BROWSER_NAMES[opt.class]
|
111
|
+
if browser
|
112
|
+
@browser_name = browser
|
113
|
+
else
|
114
|
+
W3C.each do |capability|
|
115
|
+
send("#{capability}=", opt[capability]) if opt[capability]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
@selenium_options = opts.map(&:as_json).inject(:merge) || {}
|
121
|
+
end
|
122
|
+
|
45
123
|
def create_variables(key, opts)
|
46
124
|
key.each do |option|
|
47
125
|
self.class.__send__(:attr_accessor, option)
|
@@ -53,5 +131,30 @@ module SimpleSauce
|
|
53
131
|
|
54
132
|
raise ArgumentError, "#{opts.inspect} are not valid parameters for Options class"
|
55
133
|
end
|
134
|
+
|
135
|
+
def build_name
|
136
|
+
# Jenkins
|
137
|
+
if ENV['BUILD_TAG']
|
138
|
+
"#{ENV['BUILD_NAME']}: #{ENV['BUILD_NUMBER']}"
|
139
|
+
# Bamboo
|
140
|
+
elsif ENV['bamboo_agentId']
|
141
|
+
"#{ENV['bamboo_shortJobName']}: #{ENV['bamboo_buildNumber']}"
|
142
|
+
# Travis
|
143
|
+
elsif ENV['TRAVIS_JOB_ID']
|
144
|
+
"#{ENV['TRAVIS_JOB_NAME']}: #{ENV['TRAVIS_JOB_NUMBER']}"
|
145
|
+
# CircleCI
|
146
|
+
elsif ENV['CIRCLE_JOB']
|
147
|
+
"#{ENV['CIRCLE_JOB']}: #{ENV['CIRCLE_BUILD_NUM']}"
|
148
|
+
# Gitlab
|
149
|
+
elsif ENV['CI']
|
150
|
+
"#{ENV['CI_JOB_NAME']}: #{ENV['CI_JOB_ID']}"
|
151
|
+
# Team City
|
152
|
+
elsif ENV['TEAMCITY_PROJECT_NAME']
|
153
|
+
"#{ENV['TEAMCITY_PROJECT_NAME']}: #{ENV['BUILD_NUMBER']}"
|
154
|
+
# Default
|
155
|
+
else
|
156
|
+
"Build Time - #{Time.now.to_i}"
|
157
|
+
end
|
158
|
+
end
|
56
159
|
end
|
57
160
|
end
|
data/lib/simple_sauce/session.rb
CHANGED
@@ -5,54 +5,51 @@ require 'selenium-webdriver'
|
|
5
5
|
|
6
6
|
module SimpleSauce
|
7
7
|
class Session
|
8
|
+
DATA_CENTERS = {US_WEST: 'ondemand.us-west-1.saucelabs.com',
|
9
|
+
US_EAST: 'ondemand.us-east-1.saucelabs.com',
|
10
|
+
EU_VDC: 'ondemand.eu-central-1.saucelabs.com'}.freeze
|
11
|
+
|
8
12
|
attr_writer :username, :access_key, :url
|
9
13
|
attr_reader :driver, :options, :data_center
|
10
14
|
|
11
|
-
def initialize(options = nil)
|
15
|
+
def initialize(options = nil, username: nil, access_key: nil, data_center: nil)
|
12
16
|
@options = options || Options.new
|
13
|
-
raise unless [Array, Options].include?(@options.class)
|
14
17
|
|
15
|
-
|
16
|
-
@
|
17
|
-
|
18
|
+
@username = username || ENV['SAUCE_USERNAME']
|
19
|
+
@access_key = access_key || ENV['SAUCE_ACCESS_KEY']
|
20
|
+
self.data_center = data_center || :US_WEST
|
18
21
|
end
|
19
22
|
|
20
23
|
def start
|
21
|
-
|
24
|
+
raise ArgumentError, "needs username; use `ENV['SAUCE_USERNAME']` or `Session#username=`" unless @username
|
25
|
+
raise ArgumentError, "needs access_key; use `ENV['SAUCE_ACCESS_KEY']` or `Session#access_key=`" unless @access_key
|
26
|
+
|
27
|
+
@driver = Selenium::WebDriver.for :remote, to_selenium
|
22
28
|
end
|
23
29
|
|
24
30
|
def stop(result)
|
31
|
+
return if @driver.nil?
|
32
|
+
|
25
33
|
SauceWhisk::Jobs.change_status(@driver.session_id, result)
|
26
34
|
@driver.quit
|
27
35
|
end
|
28
36
|
|
29
37
|
def data_center=(data_center)
|
38
|
+
unless DATA_CENTERS.key?(data_center)
|
39
|
+
msg = "#{data_center} is an invalid data center; specify :US_WEST, :US_EAST or :EU_VDC"
|
40
|
+
raise ArgumentError, msg
|
41
|
+
end
|
42
|
+
|
43
|
+
SauceWhisk.data_center = data_center
|
30
44
|
@data_center = data_center
|
31
|
-
@dc_url = case data_center
|
32
|
-
when :US_WEST
|
33
|
-
'ondemand.saucelabs.com:443/wd/hub'
|
34
|
-
when :US_EAST
|
35
|
-
'us-east-1.saucelabs.com:443/wd/hub'
|
36
|
-
when :EU_VDC
|
37
|
-
'ondemand.eu-central-1.saucelabs.com:443/wd/hub'
|
38
|
-
else
|
39
|
-
msg = "#{data_center} is an invalid data center; specify :US_WEST, :US_EAST or :EU_VDC"
|
40
|
-
raise ::ArgumentError, msg
|
41
|
-
end
|
42
|
-
SauceWhisk.data_center = @data_center
|
43
45
|
end
|
44
46
|
|
45
47
|
def url
|
46
|
-
|
47
|
-
unless @access_key
|
48
|
-
raise ArgumentError, "No access key was set; use `ENV['SAUCE_ACCESS_KEY']` or `Session#access_key=`"
|
49
|
-
end
|
50
|
-
|
51
|
-
@url ||= "https://#{@username}:#{@access_key}@#{@dc_url}"
|
48
|
+
@url ||= "https://#{@username}:#{@access_key}@#{DATA_CENTERS[data_center]}:443/wd/hub"
|
52
49
|
end
|
53
50
|
|
54
51
|
def to_selenium
|
55
|
-
{url: url, desired_capabilities:
|
52
|
+
{url: url, desired_capabilities: options.capabilities}
|
56
53
|
end
|
57
54
|
end
|
58
55
|
end
|
data/lib/simple_sauce/version.rb
CHANGED
data/simple_sauce.gemspec
CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'rubocop-rspec', '~>1.32'
|
28
28
|
spec.add_development_dependency 'webmock', '~> 3.5'
|
29
29
|
|
30
|
-
spec.add_runtime_dependency 'selenium-webdriver', '~> 3.0'
|
31
30
|
spec.add_runtime_dependency 'sauce_whisk'
|
32
|
-
|
31
|
+
spec.add_runtime_dependency 'selenium-webdriver', '~> 3.142.0', '>= 3.142.7'
|
33
32
|
end
|
data/spec/options.yml
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
example_values:
|
2
|
+
browser_name: 'firefox'
|
3
|
+
browser_version: '123'
|
4
|
+
platform_name: 'Mac'
|
5
|
+
accept_insecure_certs: true
|
6
|
+
page_load_strategy: 'eager'
|
7
|
+
set_window_rect: true
|
8
|
+
unhandled_prompt_behavior: "accept"
|
9
|
+
strict_file_interactability: true
|
10
|
+
timeouts:
|
11
|
+
implicit: 1
|
12
|
+
page_load: 59
|
13
|
+
script: 29
|
14
|
+
avoid_proxy: true
|
15
|
+
build: 'Sample Build Name'
|
16
|
+
capture_performance: true
|
17
|
+
chromedriver_version: '71'
|
18
|
+
command_timeout: 2
|
19
|
+
custom_data:
|
20
|
+
foo: 'foo'
|
21
|
+
bar: 'bar'
|
22
|
+
extended_debugging: true
|
23
|
+
idle_timeout: 3
|
24
|
+
iedriver_version: '3.141.0'
|
25
|
+
max_duration: 300
|
26
|
+
name: 'Sample Test Name'
|
27
|
+
parent_tunnel: 'Mommy'
|
28
|
+
prerun:
|
29
|
+
executable: "http://url.to/your/executable.exe"
|
30
|
+
args:
|
31
|
+
- --silent
|
32
|
+
- -a
|
33
|
+
- -q
|
34
|
+
background: false
|
35
|
+
timeout: 120
|
36
|
+
priority: 0
|
37
|
+
public: 'team'
|
38
|
+
record_logs: false
|
39
|
+
record_screenshots: false
|
40
|
+
record_video: false
|
41
|
+
screen_resolution: '10x10'
|
42
|
+
selenium_version: '3.141.59'
|
43
|
+
tags:
|
44
|
+
- foo
|
45
|
+
- bar
|
46
|
+
- foobar
|
47
|
+
time_zone: 'San Francisco'
|
48
|
+
tunnel_identifier: 'tunnelname'
|
49
|
+
video_upload_on_pass: false
|
50
|
+
|
51
|
+
invalid_option:
|
52
|
+
foo: "bar"
|
53
|
+
browser_name: "firefox"
|
54
|
+
browser_version: "70"
|
55
|
+
platform_name: "MacOS 10.12"
|
56
|
+
record_screenshots: false
|
data/spec/options_spec.rb
CHANGED
@@ -4,18 +4,28 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
module SimpleSauce
|
6
6
|
describe Options do
|
7
|
+
before do
|
8
|
+
ENV['BUILD_TAG'] = ''
|
9
|
+
ENV['BUILD_NAME'] = 'TEMP BUILD'
|
10
|
+
ENV['BUILD_NUMBER'] = '11'
|
11
|
+
end
|
12
|
+
|
13
|
+
after { ENV.delete 'BUILD_TAG' }
|
14
|
+
|
7
15
|
describe '#new' do
|
8
16
|
let(:default_options) do
|
9
17
|
{'browserName' => 'chrome',
|
10
18
|
'browserVersion' => 'latest',
|
11
19
|
'platformName' => 'Windows 10',
|
12
|
-
'sauce:options' => {}}
|
20
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11'}}
|
13
21
|
end
|
14
22
|
|
15
23
|
it 'uses latest Chrome version on Windows 10 by default' do
|
16
|
-
|
24
|
+
options = Options.new
|
17
25
|
|
18
|
-
expect(
|
26
|
+
expect(options.browser_name).to eq 'chrome'
|
27
|
+
expect(options.browser_version).to eq 'latest'
|
28
|
+
expect(options.platform_name).to eq 'Windows 10'
|
19
29
|
end
|
20
30
|
|
21
31
|
it 'accepts provided values for browser, browser version and platform name' do
|
@@ -28,51 +38,434 @@ module SimpleSauce
|
|
28
38
|
expect(options.platform_name).to eq 'Mac'
|
29
39
|
end
|
30
40
|
|
31
|
-
it 'accepts
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
it 'accepts other w3c values' do
|
42
|
+
proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
|
43
|
+
timeouts = {implicit: 1,
|
44
|
+
page_load: 59,
|
45
|
+
script: 29}
|
46
|
+
options = Options.new(accept_insecure_certs: true,
|
47
|
+
page_load_strategy: 'eager',
|
48
|
+
proxy: proxy,
|
49
|
+
set_window_rect: true,
|
50
|
+
unhandled_prompt_behavior: 'accept',
|
51
|
+
strict_file_interactability: true,
|
52
|
+
timeouts: timeouts)
|
53
|
+
|
54
|
+
expect(options.accept_insecure_certs).to eq true
|
55
|
+
expect(options.page_load_strategy).to eq 'eager'
|
56
|
+
expect(options.proxy).to eq proxy
|
57
|
+
expect(options.set_window_rect).to eq true
|
58
|
+
expect(options.unhandled_prompt_behavior).to eq 'accept'
|
59
|
+
expect(options.strict_file_interactability).to eq true
|
60
|
+
expect(options.timeouts).to eq timeouts
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'accepts Sauce Labs specific settings' do
|
64
|
+
custom_data = {foo: 'foo',
|
65
|
+
bar: 'bar'}
|
66
|
+
prerun = {executable: 'http://url.to/your/executable.exe',
|
67
|
+
args: ['--silent', '-a', '-q'],
|
68
|
+
background: false,
|
69
|
+
timeout: 120}
|
70
|
+
tags = %w[foo bar foobar]
|
71
|
+
sauce_options = {
|
72
|
+
avoid_proxy: true,
|
73
|
+
build: 'Sample Build Name',
|
74
|
+
capture_performance: true,
|
75
|
+
chromedriver_version: '71',
|
76
|
+
command_timeout: 2,
|
77
|
+
custom_data: custom_data,
|
78
|
+
extended_debugging: true,
|
79
|
+
idle_timeout: 3,
|
80
|
+
iedriver_version: '3.141.0',
|
81
|
+
max_duration: 300,
|
82
|
+
name: 'Sample Test Name',
|
83
|
+
parent_tunnel: 'Mommy',
|
84
|
+
prerun: prerun,
|
85
|
+
priority: 0,
|
86
|
+
public: 'team',
|
87
|
+
record_logs: false,
|
88
|
+
record_screenshots: false,
|
89
|
+
record_video: false,
|
90
|
+
screen_resolution: '10x10',
|
91
|
+
selenium_version: '3.141.59',
|
92
|
+
tags: tags,
|
93
|
+
time_zone: 'San Francisco',
|
94
|
+
tunnel_identifier: 'tunnelname',
|
95
|
+
video_upload_on_pass: false
|
96
|
+
}
|
97
|
+
|
98
|
+
options = Options.new(**sauce_options)
|
99
|
+
|
100
|
+
expect(options.avoid_proxy).to eq true
|
101
|
+
expect(options.build).to eq 'Sample Build Name'
|
102
|
+
expect(options.capture_performance).to eq true
|
103
|
+
expect(options.chromedriver_version).to eq '71'
|
104
|
+
expect(options.command_timeout).to eq 2
|
105
|
+
expect(options.custom_data).to eq custom_data
|
106
|
+
expect(options.extended_debugging).to eq true
|
107
|
+
expect(options.idle_timeout).to eq 3
|
108
|
+
expect(options.iedriver_version).to eq '3.141.0'
|
109
|
+
expect(options.max_duration).to eq 300
|
110
|
+
expect(options.name).to eq 'Sample Test Name'
|
111
|
+
expect(options.parent_tunnel).to eq 'Mommy'
|
112
|
+
expect(options.prerun).to eq prerun
|
113
|
+
expect(options.priority).to eq 0
|
114
|
+
expect(options.public).to eq 'team'
|
115
|
+
expect(options.record_logs).to eq false
|
116
|
+
expect(options.record_screenshots).to eq false
|
117
|
+
expect(options.record_video).to eq false
|
118
|
+
expect(options.screen_resolution).to eq '10x10'
|
119
|
+
expect(options.selenium_version).to eq '3.141.59'
|
120
|
+
expect(options.tags).to eq tags
|
121
|
+
expect(options.time_zone).to eq 'San Francisco'
|
122
|
+
expect(options.tunnel_identifier).to eq 'tunnelname'
|
123
|
+
expect(options.video_upload_on_pass).to eq false
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'accepts Selenium Capabilities and overrides default browser' do
|
127
|
+
caps = Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true,
|
128
|
+
page_load_strategy: 'eager')
|
129
|
+
options = Options.new(selenium_options: caps)
|
130
|
+
|
131
|
+
expect(options.browser_name).to eq 'firefox'
|
132
|
+
expect(options.accept_insecure_certs).to eq true
|
133
|
+
expect(options.page_load_strategy).to eq 'eager'
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'accepts Selenium Options and overrides default browser' do
|
137
|
+
browser_opts = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
|
138
|
+
options = Options.new(selenium_options: browser_opts)
|
51
139
|
|
52
|
-
|
140
|
+
expect(options.browser_name).to eq 'firefox'
|
141
|
+
expect(options.selenium_options['moz:firefoxOptions']).to eq('args' => ['--foo'])
|
142
|
+
end
|
53
143
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
144
|
+
it 'accepts Selenium Capabilities and Options class instances' do
|
145
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true,
|
146
|
+
page_load_strategy: 'eager')
|
147
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
|
148
|
+
options = Options.new(selenium_options: [caps, browser_opts])
|
58
149
|
|
59
|
-
expect(
|
150
|
+
expect(options.page_load_strategy).to eq 'eager'
|
151
|
+
expect(options.accept_insecure_certs).to eq true
|
152
|
+
expect(options.selenium_options['goog:chromeOptions']).to eq('args' => ['--foo'])
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'accepts W3C, Sauce, Browser Options and Capabilities at the same time' do
|
156
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome(page_load_strategy: 'eager')
|
157
|
+
browser_opts = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
|
158
|
+
|
159
|
+
options = Options.new(browser_version: '77',
|
160
|
+
accept_insecure_certs: true,
|
161
|
+
command_timeout: 2,
|
162
|
+
time_zone: 'Alaska',
|
163
|
+
selenium_options: [caps, browser_opts])
|
164
|
+
|
165
|
+
expect(options.browser_name).to eq 'firefox'
|
166
|
+
expect(options.browser_version).to eq '77'
|
167
|
+
expect(options.platform_name).to eq 'Windows 10'
|
168
|
+
expect(options.accept_insecure_certs).to eq true
|
169
|
+
expect(options.command_timeout).to eq 2
|
170
|
+
expect(options.time_zone).to eq 'Alaska'
|
171
|
+
expect(options.page_load_strategy).to eq 'eager'
|
172
|
+
|
173
|
+
expect(options.selenium_options['moz:firefoxOptions']).to eq('args' => ['--foo'])
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'creates a default build value' do
|
177
|
+
options = Options.new
|
178
|
+
expect(options.build).to eq 'TEMP BUILD: 11'
|
60
179
|
end
|
61
180
|
|
62
181
|
it 'raises ArgumentError if parameter is not recognized as valid' do
|
63
|
-
expect {
|
182
|
+
expect { Options.new(foo: 'bar') }.to raise_exception(ArgumentError)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#accessors' do
|
187
|
+
it 'parses w3c values' do
|
188
|
+
proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
|
189
|
+
timeouts = {implicit: 1,
|
190
|
+
page_load: 59,
|
191
|
+
script: 29}
|
192
|
+
|
193
|
+
options = Options.new
|
194
|
+
|
195
|
+
options.browser_name = 'firefox'
|
196
|
+
options.browser_version = '7'
|
197
|
+
options.platform_name = 'macOS 10.14'
|
198
|
+
options.accept_insecure_certs = true
|
199
|
+
options.page_load_strategy = 'eager'
|
200
|
+
options.proxy = proxy
|
201
|
+
options.set_window_rect = true
|
202
|
+
options.unhandled_prompt_behavior = 'accept'
|
203
|
+
options.strict_file_interactability = true
|
204
|
+
options.timeouts = timeouts
|
205
|
+
options.platform_name
|
206
|
+
|
207
|
+
expect(options.browser_name).to eq 'firefox'
|
208
|
+
expect(options.browser_version).to eq '7'
|
209
|
+
expect(options.platform_name).to eq 'macOS 10.14'
|
210
|
+
expect(options.accept_insecure_certs).to eq true
|
211
|
+
expect(options.page_load_strategy).to eq 'eager'
|
212
|
+
expect(options.proxy).to eq proxy
|
213
|
+
expect(options.set_window_rect).to eq true
|
214
|
+
expect(options.unhandled_prompt_behavior).to eq 'accept'
|
215
|
+
expect(options.strict_file_interactability).to eq true
|
216
|
+
expect(options.timeouts).to eq timeouts
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'parses Sauce values' do
|
220
|
+
custom_data = {foo: 'foo',
|
221
|
+
bar: 'bar'}
|
222
|
+
prerun = {executable: 'http://url.to/your/executable.exe',
|
223
|
+
args: ['--silent', '-a', '-q'],
|
224
|
+
background: false,
|
225
|
+
timeout: 120}
|
226
|
+
tags = %w[foo bar foobar]
|
227
|
+
|
228
|
+
options = Options.new
|
229
|
+
|
230
|
+
options.avoid_proxy = true
|
231
|
+
options.build = 'Sample Build Name'
|
232
|
+
options.capture_performance = true
|
233
|
+
options.chromedriver_version = '71'
|
234
|
+
options.command_timeout = 2
|
235
|
+
options.custom_data = custom_data
|
236
|
+
options.extended_debugging = true
|
237
|
+
options.idle_timeout = 3
|
238
|
+
options.iedriver_version = '3.141.0'
|
239
|
+
options.max_duration = 300
|
240
|
+
options.name = 'Sample Test Name'
|
241
|
+
options.parent_tunnel = 'Mommy'
|
242
|
+
options.prerun = prerun
|
243
|
+
options.priority = 0
|
244
|
+
options.public = 'team'
|
245
|
+
options.record_logs = false
|
246
|
+
options.record_screenshots = false
|
247
|
+
options.record_video = false
|
248
|
+
options.screen_resolution = '10x10'
|
249
|
+
options.selenium_version = '3.141.59'
|
250
|
+
options.tags = tags
|
251
|
+
options.time_zone = 'San Francisco'
|
252
|
+
options.tunnel_identifier = 'tunnelname'
|
253
|
+
options.video_upload_on_pass = false
|
254
|
+
|
255
|
+
expect(options.avoid_proxy).to eq true
|
256
|
+
expect(options.build).to eq 'Sample Build Name'
|
257
|
+
expect(options.capture_performance).to eq true
|
258
|
+
expect(options.chromedriver_version).to eq '71'
|
259
|
+
expect(options.command_timeout).to eq 2
|
260
|
+
expect(options.custom_data).to eq custom_data
|
261
|
+
expect(options.extended_debugging).to eq true
|
262
|
+
expect(options.idle_timeout).to eq 3
|
263
|
+
expect(options.iedriver_version).to eq '3.141.0'
|
264
|
+
expect(options.max_duration).to eq 300
|
265
|
+
expect(options.name).to eq 'Sample Test Name'
|
266
|
+
expect(options.parent_tunnel).to eq 'Mommy'
|
267
|
+
expect(options.prerun).to eq prerun
|
268
|
+
expect(options.priority).to eq 0
|
269
|
+
expect(options.public).to eq 'team'
|
270
|
+
expect(options.record_logs).to eq false
|
271
|
+
expect(options.record_screenshots).to eq false
|
272
|
+
expect(options.record_video).to eq false
|
273
|
+
expect(options.screen_resolution).to eq '10x10'
|
274
|
+
expect(options.selenium_version).to eq '3.141.59'
|
275
|
+
expect(options.tags).to eq tags
|
276
|
+
expect(options.time_zone).to eq 'San Francisco'
|
277
|
+
expect(options.tunnel_identifier).to eq 'tunnelname'
|
278
|
+
expect(options.video_upload_on_pass).to eq false
|
64
279
|
end
|
65
280
|
end
|
66
281
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
282
|
+
describe '#add_capabilities' do
|
283
|
+
it 'loads options from configuration' do
|
284
|
+
timeouts = {implicit: 1,
|
285
|
+
page_load: 59,
|
286
|
+
script: 29}
|
287
|
+
custom_data = {foo: 'foo',
|
288
|
+
bar: 'bar'}
|
289
|
+
prerun = {executable: 'http://url.to/your/executable.exe',
|
290
|
+
args: ['--silent', '-a', '-q'],
|
291
|
+
background: false,
|
292
|
+
timeout: 120}
|
293
|
+
tags = %w[foo bar foobar]
|
294
|
+
|
295
|
+
options = Options.new
|
296
|
+
yaml = YAML.load_file('spec/options.yml')
|
297
|
+
options.add_capabilities(yaml['example_values'])
|
298
|
+
|
299
|
+
expect(options.browser_name).to eq 'firefox'
|
300
|
+
expect(options.browser_version).to eq '123'
|
301
|
+
expect(options.platform_name).to eq 'Mac'
|
302
|
+
expect(options.accept_insecure_certs).to eq true
|
303
|
+
expect(options.page_load_strategy).to eq 'eager'
|
304
|
+
expect(options.set_window_rect).to eq true
|
305
|
+
expect(options.unhandled_prompt_behavior).to eq 'accept'
|
306
|
+
expect(options.strict_file_interactability).to eq true
|
307
|
+
expect(options.timeouts).to eq timeouts
|
308
|
+
expect(options.avoid_proxy).to eq true
|
309
|
+
expect(options.build).to eq 'Sample Build Name'
|
310
|
+
expect(options.capture_performance).to eq true
|
311
|
+
expect(options.chromedriver_version).to eq '71'
|
312
|
+
expect(options.command_timeout).to eq 2
|
313
|
+
expect(options.custom_data).to eq custom_data
|
314
|
+
expect(options.extended_debugging).to eq true
|
315
|
+
expect(options.idle_timeout).to eq 3
|
316
|
+
expect(options.iedriver_version).to eq '3.141.0'
|
317
|
+
expect(options.max_duration).to eq 300
|
318
|
+
expect(options.name).to eq 'Sample Test Name'
|
319
|
+
expect(options.parent_tunnel).to eq 'Mommy'
|
320
|
+
expect(options.prerun).to eq prerun
|
321
|
+
expect(options.priority).to eq 0
|
322
|
+
expect(options.public).to eq 'team'
|
323
|
+
expect(options.record_logs).to eq false
|
324
|
+
expect(options.record_screenshots).to eq false
|
325
|
+
expect(options.record_video).to eq false
|
326
|
+
expect(options.screen_resolution).to eq '10x10'
|
327
|
+
expect(options.selenium_version).to eq '3.141.59'
|
328
|
+
expect(options.tags).to eq tags
|
329
|
+
expect(options.time_zone).to eq 'San Francisco'
|
330
|
+
expect(options.tunnel_identifier).to eq 'tunnelname'
|
331
|
+
expect(options.video_upload_on_pass).to eq false
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'raises exception if value not recognized' do
|
335
|
+
options = Options.new
|
336
|
+
yaml = YAML.load_file('spec/options.yml')
|
337
|
+
|
338
|
+
msg = 'foo is not a valid parameter for Options class'
|
339
|
+
expect { options.add_capabilities(yaml['invalid_option']) }.to raise_exception(ArgumentError, msg)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
describe '#capabilities' do
|
344
|
+
it 'correctly generates capabilities for w3c values' do
|
345
|
+
proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
|
346
|
+
timeouts = {implicit: 1,
|
347
|
+
page_load: 59,
|
348
|
+
script: 29}
|
349
|
+
|
350
|
+
options = Options.new(browser_name: 'firefox',
|
351
|
+
platform_name: 'Mac',
|
352
|
+
accept_insecure_certs: true,
|
353
|
+
page_load_strategy: 'eager',
|
354
|
+
proxy: proxy,
|
355
|
+
set_window_rect: true,
|
356
|
+
unhandled_prompt_behavior: 'accept',
|
357
|
+
strict_file_interactability: true,
|
358
|
+
timeouts: timeouts)
|
359
|
+
|
360
|
+
expect(options.capabilities).to eq('browserName' => 'firefox',
|
361
|
+
'browserVersion' => 'latest',
|
362
|
+
'platformName' => 'Mac',
|
363
|
+
'acceptInsecureCerts' => true,
|
364
|
+
'pageLoadStrategy' => 'eager',
|
365
|
+
'proxy' => {'proxyType' => 'MANUAL', 'sslProxy' => 'foo'},
|
366
|
+
'setWindowRect' => true,
|
367
|
+
'unhandledPromptBehavior' => 'accept',
|
368
|
+
'strictFileInteractability' => true,
|
369
|
+
'timeouts' => {'implicit' => 1,
|
370
|
+
'pageLoad' => 59,
|
371
|
+
'script' => 29},
|
372
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11'})
|
373
|
+
end
|
71
374
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
375
|
+
it 'correctly generates capabilities for sauce values' do
|
376
|
+
custom_data = {foo: 'foo',
|
377
|
+
bar: 'bar'}
|
378
|
+
prerun = {'executable': 'http://url.to/your/executable.exe',
|
379
|
+
args: ['--silent', '-a', '-q'],
|
380
|
+
background: false,
|
381
|
+
timeout: 120}
|
382
|
+
tags = %w[foo bar foobar]
|
383
|
+
sauce_options = {avoid_proxy: true,
|
384
|
+
build: 'Sample Build Name',
|
385
|
+
capture_performance: true,
|
386
|
+
chromedriver_version: '71',
|
387
|
+
command_timeout: 2,
|
388
|
+
custom_data: custom_data,
|
389
|
+
extended_debugging: true,
|
390
|
+
idle_timeout: 3,
|
391
|
+
iedriver_version: '3.141.0',
|
392
|
+
max_duration: 300,
|
393
|
+
name: 'Sample Test Name',
|
394
|
+
parent_tunnel: 'Mommy',
|
395
|
+
prerun: prerun,
|
396
|
+
priority: 0,
|
397
|
+
public: 'team',
|
398
|
+
record_logs: false,
|
399
|
+
record_screenshots: false,
|
400
|
+
record_video: false,
|
401
|
+
screen_resolution: '10x10',
|
402
|
+
selenium_version: '3.141.59',
|
403
|
+
tags: tags,
|
404
|
+
time_zone: 'San Francisco',
|
405
|
+
tunnel_identifier: 'tunnelname',
|
406
|
+
video_upload_on_pass: false}
|
407
|
+
|
408
|
+
options = Options.new(**sauce_options)
|
409
|
+
|
410
|
+
prerun_caps = {'executable' => 'http://url.to/your/executable.exe',
|
411
|
+
'args' => ['--silent', '-a', '-q'],
|
412
|
+
'background' => false,
|
413
|
+
'timeout' => 120}
|
414
|
+
|
415
|
+
expect(options.capabilities).to eq('browserName' => 'chrome',
|
416
|
+
'browserVersion' => 'latest',
|
417
|
+
'platformName' => 'Windows 10',
|
418
|
+
'sauce:options' => {'build' => 'Sample Build Name',
|
419
|
+
'avoidProxy' => true,
|
420
|
+
'capturePerformance' => true,
|
421
|
+
'chromedriverVersion' => '71',
|
422
|
+
'commandTimeout' => 2,
|
423
|
+
'customData' => {'foo' => 'foo',
|
424
|
+
'bar' => 'bar'},
|
425
|
+
'extendedDebugging' => true,
|
426
|
+
'idleTimeout' => 3,
|
427
|
+
'iedriverVersion' => '3.141.0',
|
428
|
+
'maxDuration' => 300,
|
429
|
+
'name' => 'Sample Test Name',
|
430
|
+
'parentTunnel' => 'Mommy',
|
431
|
+
'prerun' => prerun_caps,
|
432
|
+
'priority' => 0,
|
433
|
+
'public' => 'team',
|
434
|
+
'recordLogs' => false,
|
435
|
+
'recordScreenshots' => false,
|
436
|
+
'recordVideo' => false,
|
437
|
+
'screenResolution' => '10x10',
|
438
|
+
'seleniumVersion' => '3.141.59',
|
439
|
+
'tags' => %w[foo bar foobar],
|
440
|
+
'timeZone' => 'San Francisco',
|
441
|
+
'tunnelIdentifier' => 'tunnelname',
|
442
|
+
'videoUploadOnPass' => false})
|
443
|
+
end
|
444
|
+
|
445
|
+
it 'correctly generates capabilities for selenium object values' do
|
446
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true,
|
447
|
+
page_load_strategy: 'eager')
|
448
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
|
449
|
+
options = Options.new(selenium_options: [caps, browser_opts])
|
450
|
+
|
451
|
+
jwp_defaults = {'cssSelectorsEnabled' => true,
|
452
|
+
'javascriptEnabled' => true,
|
453
|
+
'nativeEvents' => false,
|
454
|
+
'platform' => 'ANY',
|
455
|
+
'rotatable' => false,
|
456
|
+
'takesScreenshot' => false,
|
457
|
+
'version' => ''}
|
458
|
+
|
459
|
+
expected_caps = {'browserName' => 'chrome',
|
460
|
+
'browserVersion' => 'latest',
|
461
|
+
'platformName' => 'Windows 10',
|
462
|
+
'acceptInsecureCerts' => true,
|
463
|
+
'pageLoadStrategy' => 'eager',
|
464
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11'},
|
465
|
+
'goog:chromeOptions' => {'args' => ['--foo']}}
|
466
|
+
|
467
|
+
expect(options.capabilities).to eq(jwp_defaults.merge(expected_caps))
|
468
|
+
end
|
76
469
|
end
|
77
470
|
end
|
78
471
|
end
|
data/spec/session_spec.rb
CHANGED
@@ -12,37 +12,43 @@ module SimpleSauce
|
|
12
12
|
end
|
13
13
|
let(:default_capabilities) do
|
14
14
|
{browserName: 'chrome',
|
15
|
-
platformName: 'Windows 10',
|
16
15
|
browserVersion: 'latest',
|
17
|
-
|
16
|
+
platformName: 'Windows 10',
|
17
|
+
'sauce:options': {build: 'TEMP BUILD: 11'}}
|
18
18
|
end
|
19
19
|
|
20
20
|
def expect_request(body: nil, endpoint: nil)
|
21
21
|
body = (body || {desiredCapabilities: default_capabilities,
|
22
22
|
capabilities: {firstMatch: [default_capabilities]}}).to_json
|
23
|
-
endpoint ||= 'https://ondemand.saucelabs.com/wd/hub/session'
|
23
|
+
endpoint ||= 'https://ondemand.us-west-1.saucelabs.com/wd/hub/session'
|
24
24
|
stub_request(:post, endpoint).with(body: body).to_return(valid_response)
|
25
25
|
end
|
26
26
|
|
27
27
|
before do
|
28
|
+
ENV['BUILD_TAG'] = ''
|
29
|
+
ENV['BUILD_NAME'] = 'TEMP BUILD'
|
30
|
+
ENV['BUILD_NUMBER'] = '11'
|
28
31
|
ENV['SAUCE_USERNAME'] = 'foo'
|
29
32
|
ENV['SAUCE_ACCESS_KEY'] = '123'
|
30
33
|
end
|
31
34
|
|
32
35
|
after do
|
36
|
+
ENV.delete 'BUILD_TAG'
|
37
|
+
ENV.delete 'BUILD_NAME'
|
38
|
+
ENV.delete 'BUILD_NUMBER'
|
33
39
|
ENV.delete 'SAUCE_USERNAME'
|
34
40
|
ENV.delete 'SAUCE_ACCESS_KEY'
|
35
41
|
end
|
36
42
|
|
37
43
|
describe '#new' do
|
38
|
-
it '
|
39
|
-
session =
|
44
|
+
it 'creates default Options instance if none is provided' do
|
45
|
+
session = Session.new
|
40
46
|
|
41
|
-
expected_results = {url: 'https://foo:123@ondemand.saucelabs.com:443/wd/hub',
|
47
|
+
expected_results = {url: 'https://foo:123@ondemand.us-west-1.saucelabs.com:443/wd/hub',
|
42
48
|
desired_capabilities: {'browserName' => 'chrome',
|
43
49
|
'browserVersion' => 'latest',
|
44
50
|
'platformName' => 'Windows 10',
|
45
|
-
'sauce:options' => {}}}
|
51
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11'}}}
|
46
52
|
expect(session.to_selenium).to eq expected_results
|
47
53
|
end
|
48
54
|
|
@@ -50,58 +56,37 @@ module SimpleSauce
|
|
50
56
|
sauce_opts = Options.new(browser_version: '123',
|
51
57
|
platform_name: 'Mac',
|
52
58
|
idle_timeout: 4)
|
53
|
-
session =
|
59
|
+
session = Session.new(sauce_opts)
|
54
60
|
|
55
|
-
expected_results = {url: 'https://foo:123@ondemand.saucelabs.com:443/wd/hub',
|
61
|
+
expected_results = {url: 'https://foo:123@ondemand.us-west-1.saucelabs.com:443/wd/hub',
|
56
62
|
desired_capabilities: {'browserName' => 'chrome',
|
57
63
|
'browserVersion' => '123',
|
58
64
|
'platformName' => 'Mac',
|
59
|
-
'sauce:options' => {'idleTimeout' => 4
|
65
|
+
'sauce:options' => {'idleTimeout' => 4,
|
66
|
+
'build' => 'TEMP BUILD: 11'}}}
|
60
67
|
expect(session.to_selenium).to eq expected_results
|
61
68
|
end
|
62
69
|
|
63
|
-
it '
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
expected_capabilities = {'browserName' => 'firefox',
|
80
|
-
'platformName' => 'Mac OS',
|
81
|
-
'browserVersion' => 'latest',
|
82
|
-
'acceptInsecureCerts' => false,
|
83
|
-
'pageLoadStrategy' => 'eager',
|
84
|
-
'moz:firefoxOptions' => {args: ['-foo']},
|
85
|
-
'sauce:options' => {'idleTimeout' => 4}}
|
86
|
-
|
87
|
-
oss_capabilities = {'cssSelectorsEnabled' => false,
|
88
|
-
'javascriptEnabled' => false,
|
89
|
-
'marionette' => true,
|
90
|
-
'nativeEvents' => false,
|
91
|
-
'platform' => 'ANY',
|
92
|
-
'rotatable' => false,
|
93
|
-
'takesScreenshot' => false,
|
94
|
-
'timeouts' => {},
|
95
|
-
'version' => ''}
|
96
|
-
|
97
|
-
expected_results = {url: 'https://foo:123@ondemand.saucelabs.com:443/wd/hub',
|
98
|
-
desired_capabilities: expected_capabilities.merge(oss_capabilities)}
|
70
|
+
it 'defaults to US West data Center' do
|
71
|
+
session = Session.new
|
72
|
+
expect(session.data_center).to eq :US_WEST
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'uses provided Data Center, Username, Access Key' do
|
76
|
+
session = Session.new(data_center: :EU_VDC,
|
77
|
+
username: 'bar',
|
78
|
+
access_key: '321')
|
79
|
+
|
80
|
+
expected_results = {url: 'https://bar:321@ondemand.eu-central-1.saucelabs.com:443/wd/hub',
|
81
|
+
desired_capabilities: {'browserName' => 'chrome',
|
82
|
+
'browserVersion' => 'latest',
|
83
|
+
'platformName' => 'Windows 10',
|
84
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11'}}}
|
99
85
|
expect(session.to_selenium).to eq expected_results
|
100
86
|
end
|
101
87
|
|
102
|
-
it '
|
103
|
-
|
104
|
-
expect(session.data_center).to eq :US_WEST
|
88
|
+
it 'raises exception if data center is invalid' do
|
89
|
+
expect { Session.new(data_center: :FOO) }.to raise_exception(ArgumentError)
|
105
90
|
end
|
106
91
|
end
|
107
92
|
|
@@ -109,20 +94,20 @@ module SimpleSauce
|
|
109
94
|
it 'starts the session and returns Selenium Driver instance' do
|
110
95
|
expect_request
|
111
96
|
|
112
|
-
driver =
|
97
|
+
driver = Session.new.start
|
113
98
|
expect(driver).to be_a Selenium::WebDriver::Driver
|
114
99
|
end
|
115
100
|
|
116
101
|
it 'raises exception if no username set' do
|
117
102
|
ENV.delete('SAUCE_USERNAME')
|
118
103
|
|
119
|
-
expect {
|
104
|
+
expect { Session.new.start }.to raise_exception(ArgumentError)
|
120
105
|
end
|
121
106
|
|
122
107
|
it 'raises exception if no access key set' do
|
123
108
|
ENV.delete('SAUCE_ACCESS_KEY')
|
124
109
|
|
125
|
-
expect {
|
110
|
+
expect { Session.new.start }.to raise_exception(ArgumentError)
|
126
111
|
end
|
127
112
|
end
|
128
113
|
|
@@ -133,8 +118,7 @@ module SimpleSauce
|
|
133
118
|
allow(driver).to receive :quit
|
134
119
|
allow(SauceWhisk::Jobs).to receive(:change_status).with('1234', true)
|
135
120
|
|
136
|
-
session =
|
137
|
-
|
121
|
+
session = Session.new
|
138
122
|
session.start
|
139
123
|
session.stop(true)
|
140
124
|
|
@@ -145,14 +129,14 @@ module SimpleSauce
|
|
145
129
|
|
146
130
|
describe '#data_center=' do
|
147
131
|
it 'overrides default value for data center' do
|
148
|
-
session =
|
132
|
+
session = Session.new
|
149
133
|
session.data_center = :US_EAST
|
150
134
|
|
151
|
-
expect(session.url).to eq('https://foo:123@us-east-1.saucelabs.com:443/wd/hub')
|
135
|
+
expect(session.url).to eq('https://foo:123@ondemand.us-east-1.saucelabs.com:443/wd/hub')
|
152
136
|
end
|
153
137
|
|
154
138
|
it 'raises exception if data center is invalid' do
|
155
|
-
session =
|
139
|
+
session = Session.new
|
156
140
|
|
157
141
|
expect { session.data_center = :FOO }.to raise_exception(ArgumentError)
|
158
142
|
end
|
@@ -160,19 +144,33 @@ module SimpleSauce
|
|
160
144
|
|
161
145
|
describe '#username=' do
|
162
146
|
it 'accepts provided username' do
|
163
|
-
session =
|
147
|
+
session = Session.new
|
164
148
|
session.username = 'name'
|
165
149
|
|
166
|
-
expect(session.url).to eq('https://name:123@ondemand.saucelabs.com:443/wd/hub')
|
150
|
+
expect(session.url).to eq('https://name:123@ondemand.us-west-1.saucelabs.com:443/wd/hub')
|
167
151
|
end
|
168
152
|
end
|
169
153
|
|
170
154
|
describe '#access_key=' do
|
171
155
|
it 'accepts provided access key' do
|
172
|
-
session =
|
156
|
+
session = Session.new
|
173
157
|
session.access_key = '456'
|
174
158
|
|
175
|
-
expect(session.url).to eq('https://foo:456@ondemand.saucelabs.com:443/wd/hub')
|
159
|
+
expect(session.url).to eq('https://foo:456@ondemand.us-west-1.saucelabs.com:443/wd/hub')
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#url=' do
|
164
|
+
it 'allows user to override default URL' do
|
165
|
+
session = Session.new
|
166
|
+
session.url = 'https://bar:321@mycustomurl/foo/wd/hub:8080'
|
167
|
+
|
168
|
+
expected_results = {url: 'https://bar:321@mycustomurl/foo/wd/hub:8080',
|
169
|
+
desired_capabilities: {'browserName' => 'chrome',
|
170
|
+
'browserVersion' => 'latest',
|
171
|
+
'platformName' => 'Windows 10',
|
172
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11'}}}
|
173
|
+
expect(session.to_selenium).to eq expected_results
|
176
174
|
end
|
177
175
|
end
|
178
176
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_sauce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.pre.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,33 +109,39 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.5'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: sauce_whisk
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '0'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: selenium-webdriver
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.142.0
|
129
132
|
- - ">="
|
130
133
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
134
|
+
version: 3.142.7
|
132
135
|
type: :runtime
|
133
136
|
prerelease: false
|
134
137
|
version_requirements: !ruby/object:Gem::Requirement
|
135
138
|
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 3.142.0
|
136
142
|
- - ">="
|
137
143
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
144
|
+
version: 3.142.7
|
139
145
|
description: Reduces complexity in user code for running Selenium tests on Sauce Labs
|
140
146
|
email:
|
141
147
|
- titusfortner@gmail.com
|
@@ -156,6 +162,7 @@ files:
|
|
156
162
|
- lib/simple_sauce/session.rb
|
157
163
|
- lib/simple_sauce/version.rb
|
158
164
|
- simple_sauce.gemspec
|
165
|
+
- spec/options.yml
|
159
166
|
- spec/options_spec.rb
|
160
167
|
- spec/session_spec.rb
|
161
168
|
- spec/spec_helper.rb
|
@@ -174,15 +181,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
181
|
version: '0'
|
175
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
183
|
requirements:
|
177
|
-
- - "
|
184
|
+
- - ">"
|
178
185
|
- !ruby/object:Gem::Version
|
179
|
-
version:
|
186
|
+
version: 1.3.1
|
180
187
|
requirements: []
|
181
188
|
rubygems_version: 3.0.3
|
182
189
|
signing_key:
|
183
190
|
specification_version: 4
|
184
191
|
summary: Simple interface for interacting with Sauce Labs.
|
185
192
|
test_files:
|
193
|
+
- spec/options.yml
|
186
194
|
- spec/options_spec.rb
|
187
195
|
- spec/session_spec.rb
|
188
196
|
- spec/spec_helper.rb
|