sauce_bindings 1.1.0 → 1.2.1
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 +2 -2
- data/CHANGES.md +34 -0
- data/README.md +1 -1
- data/Rakefile +13 -1
- data/lib/sauce_bindings/base_configurations.rb +9 -0
- data/lib/sauce_bindings/chrome_configurations.rb +9 -0
- data/lib/sauce_bindings/edge_configurations.rb +9 -0
- data/lib/sauce_bindings/firefox_configurations.rb +9 -0
- data/lib/sauce_bindings/ie_configurations.rb +9 -0
- data/lib/sauce_bindings/options.rb +117 -47
- data/lib/sauce_bindings/safari_configurations.rb +9 -0
- data/lib/sauce_bindings/session.rb +7 -1
- data/lib/sauce_bindings/vdc_configurations.rb +13 -0
- data/lib/sauce_bindings/version.rb +1 -1
- data/lib/sauce_bindings.rb +7 -0
- data/sauce_bindings.gemspec +5 -3
- data/spec/deprecated_options.yml +56 -0
- data/spec/examples/accessibility_spec.rb +32 -0
- data/spec/examples/axe.min.js +1 -0
- data/spec/examples/browser_options_spec.rb +2 -4
- data/spec/examples/{basic_options_spec.rb → common_options_spec.rb} +5 -6
- data/spec/examples/create_session_spec.rb +0 -2
- data/spec/examples/data_center_spec.rb +0 -2
- data/spec/examples/sauce_options_spec.rb +1 -3
- data/spec/integration/accessibility_spec.rb +59 -0
- data/spec/integration/desktop_spec.rb +18 -14
- data/spec/options.yml +4 -8
- data/spec/spec_helper.rb +4 -0
- data/spec/unit/capybara_session_spec.rb +8 -4
- data/spec/unit/deprecated_options_spec.rb +472 -0
- data/spec/unit/options_spec.rb +339 -210
- data/spec/unit/session_spec.rb +10 -6
- metadata +45 -19
data/spec/unit/options_spec.rb
CHANGED
@@ -10,237 +10,349 @@ module SauceBindings
|
|
10
10
|
allow(ENV).to receive(:[]).with('BUILD_NUMBER').and_return('11')
|
11
11
|
end
|
12
12
|
|
13
|
-
describe '
|
14
|
-
it '
|
13
|
+
describe '::chrome' do
|
14
|
+
it 'uses latest Chrome version on Windows 10 by default' do
|
15
15
|
options = Options.chrome
|
16
16
|
|
17
17
|
expect(options.browser_name).to eq 'chrome'
|
18
18
|
expect(options.browser_version).to eq 'latest'
|
19
19
|
expect(options.platform_name).to eq 'Windows 10'
|
20
20
|
end
|
21
|
+
|
22
|
+
it 'accepts correct Selenium Options class' do
|
23
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['-foo'])
|
24
|
+
options = Options.chrome(selenium_options: browser_opts)
|
25
|
+
|
26
|
+
expect(options.selenium_options.dig('goog:chromeOptions', 'args')).to eq ['-foo']
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'does not accept incorrect Selenium Options class' do
|
30
|
+
browser_opts = Selenium::WebDriver::Firefox::Options.new
|
31
|
+
|
32
|
+
expect { Options.chrome(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'accepts correct Selenium Capabilities class' do
|
36
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.chrome(browser_version: '99')
|
37
|
+
options = Options.chrome(selenium_options: browser_opts)
|
38
|
+
|
39
|
+
expect(options.browser_version).to eq '99'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'does not accept incorrect Selenium Capabilities class' do
|
43
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.firefox(browser_version: '99')
|
44
|
+
|
45
|
+
expect { Options.chrome(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'accepts base configurations' do
|
49
|
+
options = Options.chrome(custom_data: {foo: 'bar'})
|
50
|
+
options.tags = %w[foo bar]
|
51
|
+
|
52
|
+
expect(options.custom_data).to eq(foo: 'bar')
|
53
|
+
expect(options.tags).to eq %w[foo bar]
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'accepts vdc configurations' do
|
57
|
+
options = Options.chrome(browser_version: '42.0')
|
58
|
+
options.page_load_strategy = 'eager'
|
59
|
+
|
60
|
+
expect(options.browser_version).to eq '42.0'
|
61
|
+
expect(options.page_load_strategy).to eq 'eager'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'accepts valid configurations' do
|
65
|
+
options = Options.chrome(extended_debugging: true)
|
66
|
+
options.capture_performance = true
|
67
|
+
|
68
|
+
expect(options.extended_debugging).to eq true
|
69
|
+
expect(options.capture_performance).to eq true
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'does not accept invalid configurations' do
|
73
|
+
expect { Options.chrome(geckodriver_version: 'anything') }.to raise_exception(ArgumentError)
|
74
|
+
end
|
21
75
|
end
|
22
76
|
|
23
|
-
describe '
|
24
|
-
|
25
|
-
|
77
|
+
describe '::edge' do
|
78
|
+
context 'with Selenium 3' do
|
79
|
+
before do
|
80
|
+
skip('test only applies with Selenium 3') unless Selenium::WebDriver::VERSION[0] == '3'
|
81
|
+
end
|
26
82
|
|
27
|
-
|
28
|
-
|
29
|
-
|
83
|
+
it 'raises exception' do
|
84
|
+
msg = /Selenium 3 is not compatible with the Chromium based Microsoft Edge/
|
85
|
+
expect { Options.edge }.to raise_error(ArgumentError, msg)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'with Selenium 4' do
|
90
|
+
before do
|
91
|
+
skip('test only applies with Selenium 4') unless Selenium::WebDriver::VERSION[0] == '4'
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'uses latest Edge version on Windows 10 by default' do
|
95
|
+
options = Options.edge
|
96
|
+
|
97
|
+
expect(options.browser_name).to eq 'MicrosoftEdge'
|
98
|
+
expect(options.browser_version).to eq 'latest'
|
99
|
+
expect(options.platform_name).to eq 'Windows 10'
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'accepts correct Selenium Options class' do
|
103
|
+
browser_opts = Selenium::WebDriver::Edge::Options.new(args: ['-foo'])
|
104
|
+
options = Options.edge(selenium_options: browser_opts)
|
105
|
+
|
106
|
+
expect(options.selenium_options.dig('ms:edgeOptions', 'args')).to eq ['-foo']
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'does not accept incorrect Selenium Options class' do
|
110
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new
|
111
|
+
|
112
|
+
expect { Options.edge(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'accepts correct Selenium Capabilities class' do
|
116
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.edge(browser_version: '99')
|
117
|
+
options = Options.edge(selenium_options: browser_opts)
|
118
|
+
|
119
|
+
expect(options.browser_version).to eq '99'
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'does not accept incorrect Selenium Capabilities class' do
|
123
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.chrome(browser_version: '99')
|
124
|
+
|
125
|
+
expect { Options.edge(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'accepts base configurations' do
|
129
|
+
options = Options.edge(custom_data: {foo: 'bar'})
|
130
|
+
options.tags = %w[foo bar]
|
131
|
+
|
132
|
+
expect(options.custom_data).to eq(foo: 'bar')
|
133
|
+
expect(options.tags).to eq %w[foo bar]
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'accepts vdc configurations' do
|
137
|
+
options = Options.edge(browser_version: '42.0')
|
138
|
+
options.page_load_strategy = 'eager'
|
139
|
+
|
140
|
+
expect(options.browser_version).to eq '42.0'
|
141
|
+
expect(options.page_load_strategy).to eq 'eager'
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'accepts valid configurations' do
|
145
|
+
options = Options.edge(edgedriver_version: '99')
|
146
|
+
options.selenium_version = '3.14'
|
147
|
+
|
148
|
+
expect(options.selenium_version).to eq '3.14'
|
149
|
+
expect(options.edgedriver_version).to eq '99'
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'does not accept invalid configurations' do
|
153
|
+
expect { Options.edge(chromedriver_version: 'anything') }.to raise_exception(ArgumentError)
|
154
|
+
end
|
30
155
|
end
|
31
156
|
end
|
32
157
|
|
33
|
-
describe '
|
34
|
-
it '
|
158
|
+
describe '::firefox' do
|
159
|
+
it 'uses latest Firefox version on Windows 10 by default' do
|
35
160
|
options = Options.firefox
|
36
161
|
|
37
162
|
expect(options.browser_name).to eq 'firefox'
|
38
163
|
expect(options.browser_version).to eq 'latest'
|
39
164
|
expect(options.platform_name).to eq 'Windows 10'
|
40
165
|
end
|
166
|
+
|
167
|
+
it 'accepts correct Selenium Options class' do
|
168
|
+
browser_opts = Selenium::WebDriver::Firefox::Options.new(args: ['-foo'])
|
169
|
+
options = Options.firefox(selenium_options: browser_opts)
|
170
|
+
|
171
|
+
expect(options.selenium_options.dig('moz:firefoxOptions', 'args')).to eq ['-foo']
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'does not accept incorrect Selenium Options class' do
|
175
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new
|
176
|
+
|
177
|
+
expect { Options.firefox(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'accepts correct Selenium Capabilities class' do
|
181
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.firefox(browser_version: '99')
|
182
|
+
options = Options.firefox(selenium_options: browser_opts)
|
183
|
+
|
184
|
+
expect(options.browser_version).to eq '99'
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'does not accept incorrect Selenium Capabilities class' do
|
188
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.chrome(browser_version: '99')
|
189
|
+
|
190
|
+
expect { Options.firefox(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'accepts base configurations' do
|
194
|
+
options = Options.firefox(custom_data: {foo: 'bar'})
|
195
|
+
options.tags = %w[foo bar]
|
196
|
+
|
197
|
+
expect(options.custom_data).to eq(foo: 'bar')
|
198
|
+
expect(options.tags).to eq %w[foo bar]
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'accepts vdc configurations' do
|
202
|
+
options = Options.firefox(browser_version: '42.0')
|
203
|
+
options.page_load_strategy = 'eager'
|
204
|
+
|
205
|
+
expect(options.browser_version).to eq '42.0'
|
206
|
+
expect(options.page_load_strategy).to eq 'eager'
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'accepts valid configurations' do
|
210
|
+
options = Options.firefox(extended_debugging: true)
|
211
|
+
options.selenium_version = '3.14'
|
212
|
+
|
213
|
+
expect(options.selenium_version).to eq '3.14'
|
214
|
+
expect(options.extended_debugging).to eq true
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'does not accept invalid configurations' do
|
218
|
+
expect { Options.firefox(chromedriver_version: 'anything') }.to raise_exception(ArgumentError)
|
219
|
+
end
|
41
220
|
end
|
42
221
|
|
43
|
-
describe '
|
44
|
-
it '
|
222
|
+
describe '::ie' do
|
223
|
+
it 'uses latest IE version on Windows 10 by default' do
|
45
224
|
options = Options.ie
|
46
225
|
|
47
226
|
expect(options.browser_name).to eq 'internet explorer'
|
48
227
|
expect(options.browser_version).to eq 'latest'
|
49
228
|
expect(options.platform_name).to eq 'Windows 10'
|
50
229
|
end
|
51
|
-
end
|
52
230
|
|
53
|
-
|
54
|
-
|
55
|
-
options = Options.
|
231
|
+
it 'accepts correct Selenium Options class' do
|
232
|
+
browser_opts = Selenium::WebDriver::IE::Options.new(args: ['-foo'])
|
233
|
+
options = Options.ie(selenium_options: browser_opts)
|
56
234
|
|
57
|
-
expect(options.
|
58
|
-
expect(options.browser_version).to eq 'latest'
|
59
|
-
expect(options.platform_name).to eq 'Windows 10'
|
235
|
+
expect(options.selenium_options.dig('se:ieOptions', 'ie.browserCommandLineSwitches')).to eq '-foo'
|
60
236
|
end
|
61
|
-
end
|
62
237
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
'platformName' => 'Windows 10',
|
68
|
-
'sauce:options' => {'build' => 'TEMP BUILD: 11'}}
|
238
|
+
it 'does not accept incorrect Selenium Options class' do
|
239
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new
|
240
|
+
|
241
|
+
expect { Options.ie(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
69
242
|
end
|
70
243
|
|
71
|
-
it '
|
72
|
-
|
244
|
+
it 'accepts correct Selenium Capabilities class' do
|
245
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.ie(browser_version: '99')
|
246
|
+
options = Options.ie(selenium_options: browser_opts)
|
73
247
|
|
74
|
-
expect(options.
|
75
|
-
expect(options.browser_version).to eq 'latest'
|
76
|
-
expect(options.platform_name).to eq 'Windows 10'
|
248
|
+
expect(options.browser_version).to eq '99'
|
77
249
|
end
|
78
250
|
|
79
|
-
it '
|
80
|
-
|
81
|
-
browser_version: '123',
|
82
|
-
platform_name: 'Mac')
|
251
|
+
it 'does not accept incorrect Selenium Capabilities class' do
|
252
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.chrome(browser_version: '99')
|
83
253
|
|
84
|
-
expect(
|
85
|
-
expect(options.browser_version).to eq '123'
|
86
|
-
expect(options.platform_name).to eq 'Mac'
|
254
|
+
expect { Options.ie(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
87
255
|
end
|
88
256
|
|
89
|
-
it 'accepts
|
90
|
-
|
91
|
-
|
92
|
-
page_load: 59,
|
93
|
-
script: 29}
|
94
|
-
options = Options.new(accept_insecure_certs: true,
|
95
|
-
page_load_strategy: 'eager',
|
96
|
-
proxy: proxy,
|
97
|
-
set_window_rect: true,
|
98
|
-
unhandled_prompt_behavior: 'accept',
|
99
|
-
strict_file_interactability: true,
|
100
|
-
timeouts: timeouts)
|
257
|
+
it 'accepts base configurations' do
|
258
|
+
options = Options.ie(custom_data: {foo: 'bar'})
|
259
|
+
options.tags = %w[foo bar]
|
101
260
|
|
102
|
-
expect(options.
|
261
|
+
expect(options.custom_data).to eq(foo: 'bar')
|
262
|
+
expect(options.tags).to eq %w[foo bar]
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'accepts vdc configurations' do
|
266
|
+
options = Options.ie(browser_version: '42.0')
|
267
|
+
options.page_load_strategy = 'eager'
|
268
|
+
|
269
|
+
expect(options.browser_version).to eq '42.0'
|
103
270
|
expect(options.page_load_strategy).to eq 'eager'
|
104
|
-
expect(options.proxy).to eq proxy
|
105
|
-
expect(options.set_window_rect).to eq true
|
106
|
-
expect(options.unhandled_prompt_behavior).to eq 'accept'
|
107
|
-
expect(options.strict_file_interactability).to eq true
|
108
|
-
expect(options.timeouts).to eq timeouts
|
109
271
|
end
|
110
272
|
|
111
|
-
it 'accepts
|
112
|
-
|
113
|
-
|
114
|
-
prerun = {executable: 'http://url.to/your/executable.exe',
|
115
|
-
args: ['--silent', '-a', '-q'],
|
116
|
-
background: false,
|
117
|
-
timeout: 120}
|
118
|
-
tags = %w[foo bar foobar]
|
119
|
-
sauce_options = {
|
120
|
-
avoid_proxy: true,
|
121
|
-
build: 'Sample Build Name',
|
122
|
-
capture_performance: true,
|
123
|
-
chromedriver_version: '71',
|
124
|
-
command_timeout: 2,
|
125
|
-
custom_data: custom_data,
|
126
|
-
extended_debugging: true,
|
127
|
-
idle_timeout: 3,
|
128
|
-
iedriver_version: '3.141.0',
|
129
|
-
max_duration: 300,
|
130
|
-
name: 'Sample Test Name',
|
131
|
-
parent_tunnel: 'Mommy',
|
132
|
-
prerun: prerun,
|
133
|
-
priority: 0,
|
134
|
-
public: 'team',
|
135
|
-
record_logs: false,
|
136
|
-
record_screenshots: false,
|
137
|
-
record_video: false,
|
138
|
-
screen_resolution: '10x10',
|
139
|
-
selenium_version: '3.141.59',
|
140
|
-
tags: tags,
|
141
|
-
time_zone: 'San Francisco',
|
142
|
-
tunnel_identifier: 'tunnelname',
|
143
|
-
video_upload_on_pass: false
|
144
|
-
}
|
145
|
-
|
146
|
-
options = Options.new(**sauce_options)
|
273
|
+
it 'accepts valid configurations' do
|
274
|
+
options = Options.ie(avoid_proxy: true)
|
275
|
+
options.selenium_version = '3.14'
|
147
276
|
|
277
|
+
expect(options.selenium_version).to eq '3.14'
|
148
278
|
expect(options.avoid_proxy).to eq true
|
149
|
-
expect(options.build).to eq 'Sample Build Name'
|
150
|
-
expect(options.capture_performance).to eq true
|
151
|
-
expect(options.chromedriver_version).to eq '71'
|
152
|
-
expect(options.command_timeout).to eq 2
|
153
|
-
expect(options.custom_data).to eq custom_data
|
154
|
-
expect(options.extended_debugging).to eq true
|
155
|
-
expect(options.idle_timeout).to eq 3
|
156
|
-
expect(options.iedriver_version).to eq '3.141.0'
|
157
|
-
expect(options.max_duration).to eq 300
|
158
|
-
expect(options.name).to eq 'Sample Test Name'
|
159
|
-
expect(options.parent_tunnel).to eq 'Mommy'
|
160
|
-
expect(options.prerun).to eq prerun
|
161
|
-
expect(options.priority).to eq 0
|
162
|
-
expect(options.public).to eq 'team'
|
163
|
-
expect(options.record_logs).to eq false
|
164
|
-
expect(options.record_screenshots).to eq false
|
165
|
-
expect(options.record_video).to eq false
|
166
|
-
expect(options.screen_resolution).to eq '10x10'
|
167
|
-
expect(options.selenium_version).to eq '3.141.59'
|
168
|
-
expect(options.tags).to eq tags
|
169
|
-
expect(options.time_zone).to eq 'San Francisco'
|
170
|
-
expect(options.tunnel_identifier).to eq 'tunnelname'
|
171
|
-
expect(options.video_upload_on_pass).to eq false
|
172
279
|
end
|
173
280
|
|
174
|
-
it '
|
175
|
-
|
176
|
-
|
177
|
-
|
281
|
+
it 'does not accept invalid configurations' do
|
282
|
+
expect { Options.ie(chromedriver_version: 'anything') }.to raise_exception(ArgumentError)
|
283
|
+
end
|
284
|
+
end
|
178
285
|
|
179
|
-
|
180
|
-
|
181
|
-
|
286
|
+
describe '::safari' do
|
287
|
+
it 'uses latest Safari version on latest macOS by default' do
|
288
|
+
options = Options.safari
|
289
|
+
|
290
|
+
expect(options.browser_name).to eq 'safari'
|
291
|
+
expect(options.browser_version).to eq 'latest'
|
292
|
+
expect(options.platform_name).to eq 'macOS 11'
|
182
293
|
end
|
183
294
|
|
184
|
-
it 'accepts Selenium Options
|
185
|
-
browser_opts = Selenium::WebDriver::
|
186
|
-
options = Options.
|
295
|
+
it 'accepts correct Selenium Options class' do
|
296
|
+
browser_opts = Selenium::WebDriver::Safari::Options.new(automatic_inspection: true)
|
297
|
+
options = Options.safari(selenium_options: browser_opts)
|
187
298
|
|
188
|
-
expect(options.
|
189
|
-
expect(options.selenium_options['moz:firefoxOptions']).to eq('args' => ['--foo'])
|
299
|
+
expect(options.selenium_options['safari:automaticInspection']).to eq true
|
190
300
|
end
|
191
301
|
|
192
|
-
it '
|
193
|
-
|
194
|
-
page_load_strategy: 'eager')
|
195
|
-
browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
|
196
|
-
options = Options.new(selenium_options: [caps, browser_opts])
|
302
|
+
it 'does not accept incorrect Selenium Options class' do
|
303
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new
|
197
304
|
|
198
|
-
expect(
|
199
|
-
expect(options.accept_insecure_certs).to eq true
|
200
|
-
expect(options.selenium_options['goog:chromeOptions']).to eq('args' => ['--foo'])
|
305
|
+
expect { Options.safari(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
201
306
|
end
|
202
307
|
|
203
|
-
it 'accepts
|
204
|
-
|
205
|
-
|
308
|
+
it 'accepts correct Selenium Capabilities class' do
|
309
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.safari(browser_version: '99')
|
310
|
+
options = Options.safari(selenium_options: browser_opts)
|
206
311
|
|
207
|
-
options
|
208
|
-
|
209
|
-
command_timeout: 2,
|
210
|
-
time_zone: 'Alaska',
|
211
|
-
selenium_options: [caps, browser_opts])
|
312
|
+
expect(options.browser_version).to eq '99'
|
313
|
+
end
|
212
314
|
|
213
|
-
|
214
|
-
|
215
|
-
expect(options.platform_name).to eq 'Windows 10'
|
216
|
-
expect(options.accept_insecure_certs).to eq true
|
217
|
-
expect(options.command_timeout).to eq 2
|
218
|
-
expect(options.time_zone).to eq 'Alaska'
|
219
|
-
expect(options.page_load_strategy).to eq 'eager'
|
315
|
+
it 'does not accept incorrect Selenium Capabilities class' do
|
316
|
+
browser_opts = Selenium::WebDriver::Remote::Capabilities.chrome(browser_version: '99')
|
220
317
|
|
221
|
-
expect(
|
318
|
+
expect { Options.safari(selenium_options: browser_opts) }.to raise_exception(ArgumentError)
|
222
319
|
end
|
223
320
|
|
224
|
-
it '
|
225
|
-
options = Options.
|
226
|
-
|
321
|
+
it 'accepts base configurations' do
|
322
|
+
options = Options.safari(custom_data: {foo: 'bar'})
|
323
|
+
options.tags = %w[foo bar]
|
324
|
+
|
325
|
+
expect(options.custom_data).to eq(foo: 'bar')
|
326
|
+
expect(options.tags).to eq %w[foo bar]
|
227
327
|
end
|
228
328
|
|
229
|
-
it '
|
230
|
-
|
329
|
+
it 'accepts vdc configurations' do
|
330
|
+
options = Options.safari(browser_version: '42.0')
|
331
|
+
options.page_load_strategy = 'eager'
|
332
|
+
|
333
|
+
expect(options.browser_version).to eq '42.0'
|
334
|
+
expect(options.page_load_strategy).to eq 'eager'
|
335
|
+
end
|
336
|
+
|
337
|
+
it 'accepts valid configurations' do
|
338
|
+
options = Options.safari(avoid_proxy: true)
|
339
|
+
options.selenium_version = '3.14'
|
340
|
+
|
341
|
+
expect(options.selenium_version).to eq '3.14'
|
342
|
+
expect(options.avoid_proxy).to eq true
|
343
|
+
end
|
344
|
+
|
345
|
+
it 'does not accept invalid configurations' do
|
346
|
+
expect { Options.safari(chromedriver_version: 'anything') }.to raise_exception(ArgumentError)
|
231
347
|
end
|
232
348
|
end
|
233
349
|
|
234
350
|
describe '#accessors' do
|
235
351
|
it 'parses w3c values' do
|
236
352
|
proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
|
237
|
-
timeouts = {implicit: 1,
|
238
|
-
page_load: 59,
|
239
|
-
script: 29}
|
240
353
|
|
241
|
-
options = Options.
|
354
|
+
options = Options.firefox
|
242
355
|
|
243
|
-
options.browser_name = 'firefox'
|
244
356
|
options.browser_version = '7'
|
245
357
|
options.platform_name = 'macOS 10.14'
|
246
358
|
options.accept_insecure_certs = true
|
@@ -249,7 +361,9 @@ module SauceBindings
|
|
249
361
|
options.set_window_rect = true
|
250
362
|
options.unhandled_prompt_behavior = 'accept'
|
251
363
|
options.strict_file_interactability = true
|
252
|
-
options.
|
364
|
+
options.implicit_wait_timeout = 1
|
365
|
+
options.page_load_timeout = 59
|
366
|
+
options.script_timeout = 29
|
253
367
|
|
254
368
|
expect(options.browser_name).to eq 'firefox'
|
255
369
|
expect(options.browser_version).to eq '7'
|
@@ -260,7 +374,9 @@ module SauceBindings
|
|
260
374
|
expect(options.set_window_rect).to eq true
|
261
375
|
expect(options.unhandled_prompt_behavior).to eq 'accept'
|
262
376
|
expect(options.strict_file_interactability).to eq true
|
263
|
-
expect(options.
|
377
|
+
expect(options.implicit_wait_timeout).to eq 1
|
378
|
+
expect(options.page_load_timeout).to eq 59
|
379
|
+
expect(options.script_timeout).to eq 29
|
264
380
|
end
|
265
381
|
|
266
382
|
it 'parses Sauce values' do
|
@@ -272,17 +388,13 @@ module SauceBindings
|
|
272
388
|
timeout: 120}
|
273
389
|
tags = %w[foo bar foobar]
|
274
390
|
|
275
|
-
options = Options.
|
391
|
+
options = Options.firefox
|
276
392
|
|
277
|
-
options.avoid_proxy = true
|
278
393
|
options.build = 'Sample Build Name'
|
279
|
-
options.capture_performance = true
|
280
|
-
options.chromedriver_version = '71'
|
281
394
|
options.command_timeout = 2
|
282
395
|
options.custom_data = custom_data
|
283
396
|
options.extended_debugging = true
|
284
397
|
options.idle_timeout = 3
|
285
|
-
options.iedriver_version = '3.141.0'
|
286
398
|
options.max_duration = 300
|
287
399
|
options.name = 'Sample Test Name'
|
288
400
|
options.parent_tunnel = 'Mommy'
|
@@ -299,15 +411,11 @@ module SauceBindings
|
|
299
411
|
options.tunnel_identifier = 'tunnelname'
|
300
412
|
options.video_upload_on_pass = false
|
301
413
|
|
302
|
-
expect(options.avoid_proxy).to eq true
|
303
414
|
expect(options.build).to eq 'Sample Build Name'
|
304
|
-
expect(options.capture_performance).to eq true
|
305
|
-
expect(options.chromedriver_version).to eq '71'
|
306
415
|
expect(options.command_timeout).to eq 2
|
307
416
|
expect(options.custom_data).to eq custom_data
|
308
417
|
expect(options.extended_debugging).to eq true
|
309
418
|
expect(options.idle_timeout).to eq 3
|
310
|
-
expect(options.iedriver_version).to eq '3.141.0'
|
311
419
|
expect(options.max_duration).to eq 300
|
312
420
|
expect(options.name).to eq 'Sample Test Name'
|
313
421
|
expect(options.parent_tunnel).to eq 'Mommy'
|
@@ -328,9 +436,6 @@ module SauceBindings
|
|
328
436
|
|
329
437
|
describe '#merge_capabilities' do
|
330
438
|
it 'loads options from configuration' do
|
331
|
-
timeouts = {implicit: 1,
|
332
|
-
page_load: 59,
|
333
|
-
script: 29}
|
334
439
|
custom_data = {foo: 'foo',
|
335
440
|
bar: 'bar'}
|
336
441
|
prerun = {executable: 'http://url.to/your/executable.exe',
|
@@ -339,9 +444,10 @@ module SauceBindings
|
|
339
444
|
timeout: 120}
|
340
445
|
tags = %w[foo bar foobar]
|
341
446
|
|
342
|
-
options = Options.new
|
343
447
|
yaml = YAML.load_file('spec/options.yml')
|
344
|
-
|
448
|
+
example_values = yaml['example_values']
|
449
|
+
options = Options.send(example_values.delete('browser_name'))
|
450
|
+
options.merge_capabilities(example_values)
|
345
451
|
|
346
452
|
expect(options.browser_name).to eq 'firefox'
|
347
453
|
expect(options.browser_version).to eq '123'
|
@@ -351,16 +457,15 @@ module SauceBindings
|
|
351
457
|
expect(options.set_window_rect).to eq true
|
352
458
|
expect(options.unhandled_prompt_behavior).to eq 'accept'
|
353
459
|
expect(options.strict_file_interactability).to eq true
|
354
|
-
expect(options.
|
355
|
-
expect(options.
|
460
|
+
expect(options.implicit_wait_timeout).to eq 1
|
461
|
+
expect(options.page_load_timeout).to eq 59
|
462
|
+
expect(options.script_timeout).to eq 29
|
356
463
|
expect(options.build).to eq 'Sample Build Name'
|
357
|
-
expect(options.capture_performance).to eq true
|
358
|
-
expect(options.chromedriver_version).to eq '71'
|
359
464
|
expect(options.command_timeout).to eq 2
|
360
465
|
expect(options.custom_data).to eq custom_data
|
361
466
|
expect(options.extended_debugging).to eq true
|
362
467
|
expect(options.idle_timeout).to eq 3
|
363
|
-
expect(options.
|
468
|
+
expect(options.geckodriver_version).to eq '0.23'
|
364
469
|
expect(options.max_duration).to eq 300
|
365
470
|
expect(options.name).to eq 'Sample Test Name'
|
366
471
|
expect(options.parent_tunnel).to eq 'Mommy'
|
@@ -379,7 +484,7 @@ module SauceBindings
|
|
379
484
|
end
|
380
485
|
|
381
486
|
it 'raises exception if value not recognized' do
|
382
|
-
options = Options.
|
487
|
+
options = Options.chrome
|
383
488
|
yaml = YAML.load_file('spec/options.yml')
|
384
489
|
|
385
490
|
msg = 'foo is not a valid parameter for Options class'
|
@@ -388,34 +493,39 @@ module SauceBindings
|
|
388
493
|
end
|
389
494
|
|
390
495
|
describe '#capabilities' do
|
496
|
+
it 'errors when timeouts are milliseconds' do
|
497
|
+
expect { Options.chrome(implicit_wait_timeout: 601).capabilities }.to raise_error(ArgumentError)
|
498
|
+
expect { Options.chrome(page_load_timeout: 601).capabilities }.to raise_error(ArgumentError)
|
499
|
+
expect { Options.chrome(script_timeout: 601).capabilities }.to raise_error(ArgumentError)
|
500
|
+
end
|
501
|
+
|
391
502
|
it 'correctly generates capabilities for w3c values' do
|
392
503
|
proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
timeouts: timeouts)
|
504
|
+
|
505
|
+
options = Options.firefox(platform_name: 'Mac',
|
506
|
+
accept_insecure_certs: true,
|
507
|
+
page_load_strategy: 'eager',
|
508
|
+
proxy: proxy,
|
509
|
+
set_window_rect: true,
|
510
|
+
unhandled_prompt_behavior: 'accept',
|
511
|
+
strict_file_interactability: true,
|
512
|
+
implicit_wait_timeout: 1,
|
513
|
+
page_load_timeout: 59,
|
514
|
+
script_timeout: 29)
|
515
|
+
proxy_type = Selenium::WebDriver::VERSION[0] == '3' ? 'MANUAL' : 'manual'
|
406
516
|
|
407
517
|
expect(options.capabilities).to eq('browserName' => 'firefox',
|
408
518
|
'browserVersion' => 'latest',
|
409
519
|
'platformName' => 'Mac',
|
410
520
|
'acceptInsecureCerts' => true,
|
411
521
|
'pageLoadStrategy' => 'eager',
|
412
|
-
'proxy' => {'proxyType' =>
|
522
|
+
'proxy' => {'proxyType' => proxy_type, 'sslProxy' => 'foo'},
|
413
523
|
'setWindowRect' => true,
|
414
524
|
'unhandledPromptBehavior' => 'accept',
|
415
525
|
'strictFileInteractability' => true,
|
416
|
-
'timeouts' => {'implicit' =>
|
417
|
-
'pageLoad' =>
|
418
|
-
'script' =>
|
526
|
+
'timeouts' => {'implicit' => 1000,
|
527
|
+
'pageLoad' => 59_000,
|
528
|
+
'script' => 29_000},
|
419
529
|
'sauce:options' => {'build' => 'TEMP BUILD: 11'})
|
420
530
|
end
|
421
531
|
|
@@ -427,15 +537,13 @@ module SauceBindings
|
|
427
537
|
background: false,
|
428
538
|
timeout: 120}
|
429
539
|
tags = %w[foo bar foobar]
|
430
|
-
sauce_options = {
|
431
|
-
build: 'Sample Build Name',
|
540
|
+
sauce_options = {build: 'Sample Build Name',
|
432
541
|
capture_performance: true,
|
433
542
|
chromedriver_version: '71',
|
434
543
|
command_timeout: 2,
|
435
544
|
custom_data: custom_data,
|
436
545
|
extended_debugging: true,
|
437
546
|
idle_timeout: 3,
|
438
|
-
iedriver_version: '3.141.0',
|
439
547
|
max_duration: 300,
|
440
548
|
name: 'Sample Test Name',
|
441
549
|
parent_tunnel: 'Mommy',
|
@@ -446,13 +554,12 @@ module SauceBindings
|
|
446
554
|
record_screenshots: false,
|
447
555
|
record_video: false,
|
448
556
|
screen_resolution: '10x10',
|
449
|
-
selenium_version: '3.141.59',
|
450
557
|
tags: tags,
|
451
558
|
time_zone: 'San Francisco',
|
452
559
|
tunnel_identifier: 'tunnelname',
|
453
560
|
video_upload_on_pass: false}
|
454
561
|
|
455
|
-
options = Options.
|
562
|
+
options = Options.chrome(**sauce_options)
|
456
563
|
|
457
564
|
prerun_caps = {'executable' => 'http://url.to/your/executable.exe',
|
458
565
|
'args' => ['--silent', '-a', '-q'],
|
@@ -463,7 +570,6 @@ module SauceBindings
|
|
463
570
|
'browserVersion' => 'latest',
|
464
571
|
'platformName' => 'Windows 10',
|
465
572
|
'sauce:options' => {'build' => 'Sample Build Name',
|
466
|
-
'avoidProxy' => true,
|
467
573
|
'capturePerformance' => true,
|
468
574
|
'chromedriverVersion' => '71',
|
469
575
|
'commandTimeout' => 2,
|
@@ -471,7 +577,6 @@ module SauceBindings
|
|
471
577
|
'bar' => 'bar'},
|
472
578
|
'extendedDebugging' => true,
|
473
579
|
'idleTimeout' => 3,
|
474
|
-
'iedriverVersion' => '3.141.0',
|
475
580
|
'maxDuration' => 300,
|
476
581
|
'name' => 'Sample Test Name',
|
477
582
|
'parentTunnel' => 'Mommy',
|
@@ -482,18 +587,19 @@ module SauceBindings
|
|
482
587
|
'recordScreenshots' => false,
|
483
588
|
'recordVideo' => false,
|
484
589
|
'screenResolution' => '10x10',
|
485
|
-
'seleniumVersion' => '3.141.59',
|
486
590
|
'tags' => %w[foo bar foobar],
|
487
591
|
'timeZone' => 'San Francisco',
|
488
592
|
'tunnelIdentifier' => 'tunnelname',
|
489
593
|
'videoUploadOnPass' => false})
|
490
594
|
end
|
491
595
|
|
492
|
-
it 'correctly generates capabilities for selenium object values' do
|
596
|
+
it 'correctly generates capabilities for selenium object values Selenium 3' do
|
597
|
+
skip unless Selenium::WebDriver::VERSION[0] == '3'
|
598
|
+
|
493
599
|
caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true,
|
494
600
|
page_load_strategy: 'eager')
|
495
601
|
browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
|
496
|
-
options = Options.
|
602
|
+
options = Options.chrome(selenium_options: [caps, browser_opts])
|
497
603
|
|
498
604
|
jwp_defaults = {'cssSelectorsEnabled' => true,
|
499
605
|
'javascriptEnabled' => true,
|
@@ -513,6 +619,29 @@ module SauceBindings
|
|
513
619
|
|
514
620
|
expect(options.capabilities).to eq(jwp_defaults.merge(expected_caps))
|
515
621
|
end
|
622
|
+
|
623
|
+
it 'correctly generates capabilities for selenium object values Selenium 4' do
|
624
|
+
skip if Selenium::WebDriver::VERSION[0] == '3'
|
625
|
+
|
626
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true)
|
627
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'],
|
628
|
+
page_load_strategy: 'eager')
|
629
|
+
options = Options.chrome(selenium_options: [caps, browser_opts])
|
630
|
+
|
631
|
+
expect(options.accept_insecure_certs).to eq true
|
632
|
+
expect(options.page_load_strategy).to eq 'eager'
|
633
|
+
expect(options.selenium_options.dig('goog:chromeOptions', 'args')).to eq ['--foo']
|
634
|
+
|
635
|
+
expected_caps = {'browserName' => 'chrome',
|
636
|
+
'browserVersion' => 'latest',
|
637
|
+
'platformName' => 'Windows 10',
|
638
|
+
'acceptInsecureCerts' => true,
|
639
|
+
'pageLoadStrategy' => 'eager',
|
640
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11'},
|
641
|
+
'goog:chromeOptions' => {'args' => ['--foo']}}
|
642
|
+
|
643
|
+
expect(options.capabilities).to eq expected_caps
|
644
|
+
end
|
516
645
|
end
|
517
646
|
end
|
518
647
|
end
|