sauce_bindings 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,468 +4,491 @@ require 'spec_helper'
4
4
 
5
5
  module SauceBindings
6
6
  describe Options do
7
- before do
8
- allow(ENV).to receive(:[]).with('BUILD_TAG').and_return('')
9
- allow(ENV).to receive(:[]).with('BUILD_NAME').and_return('TEMP BUILD')
10
- allow(ENV).to receive(:[]).with('BUILD_NUMBER').and_return('11')
11
- end
12
-
13
- describe '#new' do
14
- let(:default_options) do
15
- {'browserName' => 'chrome',
16
- 'browserVersion' => 'latest',
17
- 'platformName' => 'Windows 10',
18
- 'sauce:options' => {'build' => 'TEMP BUILD: 11'}}
19
- end
20
-
21
- it 'uses latest Chrome version on Windows 10 by default' do
22
- options = Options.new
23
-
24
- expect(options.browser_name).to eq 'chrome'
25
- expect(options.browser_version).to eq 'latest'
26
- expect(options.platform_name).to eq 'Windows 10'
27
- end
28
-
29
- it 'accepts provided values for browser, browser version and platform name' do
30
- options = Options.new(browser_name: 'firefox',
31
- browser_version: '123',
32
- platform_name: 'Mac')
33
-
34
- expect(options.browser_name).to eq 'firefox'
35
- expect(options.browser_version).to eq '123'
36
- expect(options.platform_name).to eq 'Mac'
37
- end
38
-
39
- it 'accepts other w3c values' do
40
- proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
41
- timeouts = {implicit: 1,
42
- page_load: 59,
43
- script: 29}
44
- options = Options.new(accept_insecure_certs: true,
45
- page_load_strategy: 'eager',
46
- proxy: proxy,
47
- set_window_rect: true,
48
- unhandled_prompt_behavior: 'accept',
49
- strict_file_interactability: true,
50
- timeouts: timeouts)
51
-
52
- expect(options.accept_insecure_certs).to eq true
53
- expect(options.page_load_strategy).to eq 'eager'
54
- expect(options.proxy).to eq proxy
55
- expect(options.set_window_rect).to eq true
56
- expect(options.unhandled_prompt_behavior).to eq 'accept'
57
- expect(options.strict_file_interactability).to eq true
58
- expect(options.timeouts).to eq timeouts
7
+ context 'when using deprecated methods' do
8
+ describe '#new' do
9
+ let(:default_options) do
10
+ {'browserName' => 'chrome',
11
+ 'browserVersion' => 'latest',
12
+ 'platformName' => 'Windows 10',
13
+ 'sauce:options' => {'build' => 'TEMP BUILD: 11'}}
14
+ end
15
+
16
+ it 'uses latest Chrome version on Windows 10 by default' do
17
+ expect { @options = Options.new }.to have_deprecated_options_init
18
+
19
+ expect(@options.browser_name).to eq 'chrome'
20
+ expect(@options.browser_version).to eq 'latest'
21
+ expect(@options.platform_name).to eq 'Windows 10'
22
+ end
23
+
24
+ it 'accepts provided values for browser, browser version and platform name' do
25
+ expect {
26
+ @options = Options.new(browser_name: 'firefox',
27
+ browser_version: '123',
28
+ platform_name: 'Mac')
29
+ }.to have_deprecated_options_init
30
+
31
+ expect(@options.browser_name).to eq 'firefox'
32
+ expect(@options.browser_version).to eq '123'
33
+ expect(@options.platform_name).to eq 'Mac'
34
+ end
35
+
36
+ it 'accepts other w3c values' do
37
+ proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
38
+ timeouts = {implicit: 1,
39
+ page_load: 59,
40
+ script: 29}
41
+ expect {
42
+ @options = Options.new(accept_insecure_certs: true,
43
+ page_load_strategy: 'eager',
44
+ proxy: proxy,
45
+ set_window_rect: true,
46
+ unhandled_prompt_behavior: 'accept',
47
+ strict_file_interactability: true,
48
+ timeouts: timeouts)
49
+ }.to have_deprecated_options_init
50
+
51
+ expect(@options.accept_insecure_certs).to eq true
52
+ expect(@options.page_load_strategy).to eq 'eager'
53
+ expect(@options.proxy).to eq proxy
54
+ expect(@options.set_window_rect).to eq true
55
+ expect(@options.unhandled_prompt_behavior).to eq 'accept'
56
+ expect(@options.strict_file_interactability).to eq true
57
+ expect(@options.timeouts).to eq timeouts
58
+ end
59
+
60
+ it 'accepts Sauce Labs specific settings' do
61
+ custom_data = {foo: 'foo',
62
+ bar: 'bar'}
63
+ prerun = {executable: 'http://url.to/your/executable.exe',
64
+ args: ['--silent', '-a', '-q'],
65
+ background: false,
66
+ timeout: 120}
67
+ tags = %w[foo bar foobar]
68
+ sauce_options = {
69
+ avoid_proxy: true,
70
+ build: 'Sample Build Name',
71
+ capture_performance: true,
72
+ chromedriver_version: '71',
73
+ command_timeout: 2,
74
+ custom_data: custom_data,
75
+ extended_debugging: true,
76
+ idle_timeout: 3,
77
+ iedriver_version: '3.141.0',
78
+ max_duration: 300,
79
+ name: 'Sample Test Name',
80
+ parent_tunnel: 'Mommy',
81
+ prerun: prerun,
82
+ priority: 0,
83
+ public: 'team',
84
+ record_logs: false,
85
+ record_screenshots: false,
86
+ record_video: false,
87
+ screen_resolution: '10x10',
88
+ selenium_version: '3.141.59',
89
+ tags: tags,
90
+ time_zone: 'San Francisco',
91
+ tunnel_identifier: 'tunnelname',
92
+ video_upload_on_pass: false
93
+ }
94
+
95
+ expect { @options = Options.new(**sauce_options) }.to have_deprecated_options_init
96
+
97
+ expect(@options.avoid_proxy).to eq true
98
+ expect(@options.build).to eq 'Sample Build Name'
99
+ expect(@options.capture_performance).to eq true
100
+ expect(@options.chromedriver_version).to eq '71'
101
+ expect(@options.command_timeout).to eq 2
102
+ expect(@options.custom_data).to eq custom_data
103
+ expect(@options.extended_debugging).to eq true
104
+ expect(@options.idle_timeout).to eq 3
105
+ expect(@options.iedriver_version).to eq '3.141.0'
106
+ expect(@options.max_duration).to eq 300
107
+ expect(@options.name).to eq 'Sample Test Name'
108
+ expect(@options.parent_tunnel).to eq 'Mommy'
109
+ expect(@options.prerun).to eq prerun
110
+ expect(@options.priority).to eq 0
111
+ expect(@options.public).to eq 'team'
112
+ expect(@options.record_logs).to eq false
113
+ expect(@options.record_screenshots).to eq false
114
+ expect(@options.record_video).to eq false
115
+ expect(@options.screen_resolution).to eq '10x10'
116
+ expect(@options.selenium_version).to eq '3.141.59'
117
+ expect(@options.tags).to eq tags
118
+ expect(@options.time_zone).to eq 'San Francisco'
119
+ expect(@options.tunnel_identifier).to eq 'tunnelname'
120
+ expect(@options.video_upload_on_pass).to eq false
121
+ end
122
+
123
+ it 'accepts Selenium Capabilities and overrides default browser' do
124
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true,
125
+ page_load_strategy: 'eager')
126
+ expect { @options = Options.new(selenium_options: caps) }.to have_deprecated_options_init
127
+
128
+ expect(@options.browser_name).to eq 'firefox'
129
+ expect(@options.accept_insecure_certs).to eq true
130
+ expect(@options.page_load_strategy).to eq 'eager'
131
+ end
132
+
133
+ it 'accepts Selenium Options and overrides default browser' do
134
+ browser_opts = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
135
+ expect { @options = Options.new(selenium_options: browser_opts) }.to have_deprecated_options_init
136
+
137
+ expect(@options.browser_name).to eq 'firefox'
138
+ expect(@options.selenium_options['moz:firefoxOptions']).to eq('args' => ['--foo'])
139
+ end
140
+
141
+ it 'accepts Selenium Capabilities and Options class instances' do
142
+ caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true,
143
+ page_load_strategy: 'eager')
144
+ browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
145
+ expect { @options = Options.new(selenium_options: [caps, browser_opts]) }.to have_deprecated_options_init
146
+
147
+ expect(@options.page_load_strategy).to eq 'eager'
148
+ expect(@options.accept_insecure_certs).to eq true
149
+ expect(@options.selenium_options['goog:chromeOptions']).to eq('args' => ['--foo'])
150
+ end
151
+
152
+ it 'accepts W3C, Sauce, Browser Options and Capabilities at the same time' do
153
+ caps = Selenium::WebDriver::Remote::Capabilities.chrome(page_load_strategy: 'eager')
154
+ browser_opts = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
155
+
156
+ expect {
157
+ @options = Options.new(browser_version: '77',
158
+ accept_insecure_certs: true,
159
+ command_timeout: 2,
160
+ time_zone: 'Alaska',
161
+ selenium_options: [caps, browser_opts])
162
+ }.to have_deprecated_options_init
163
+
164
+ expect(@options.browser_name).to eq 'firefox'
165
+ expect(@options.browser_version).to eq '77'
166
+ expect(@options.platform_name).to eq 'Windows 10'
167
+ expect(@options.accept_insecure_certs).to eq true
168
+ expect(@options.command_timeout).to eq 2
169
+ expect(@options.time_zone).to eq 'Alaska'
170
+ expect(@options.page_load_strategy).to eq 'eager'
171
+
172
+ expect(@options.selenium_options['moz:firefoxOptions']).to eq('args' => ['--foo'])
173
+ end
174
+
175
+ it 'creates a default build value' do
176
+ ClimateControl.modify(**BUILD_ENV) do
177
+ expect { @options = Options.new }.to have_deprecated_options_init
178
+ end
179
+
180
+ expect(@options.build).to eq 'TEMP BUILD: 11'
181
+ end
182
+
183
+ it 'raises ArgumentError if parameter is not recognized as valid' do
184
+ expect {
185
+ expect { @options = Options.new(foo: 'bar') }.to have_deprecated_options_init
186
+ }.to raise_exception(ArgumentError)
187
+ end
59
188
  end
60
189
 
61
- it 'accepts Sauce Labs specific settings' do
62
- custom_data = {foo: 'foo',
63
- bar: 'bar'}
64
- prerun = {executable: 'http://url.to/your/executable.exe',
65
- args: ['--silent', '-a', '-q'],
66
- background: false,
67
- timeout: 120}
68
- tags = %w[foo bar foobar]
69
- sauce_options = {
70
- avoid_proxy: true,
71
- build: 'Sample Build Name',
72
- capture_performance: true,
73
- chromedriver_version: '71',
74
- command_timeout: 2,
75
- custom_data: custom_data,
76
- extended_debugging: true,
77
- idle_timeout: 3,
78
- iedriver_version: '3.141.0',
79
- max_duration: 300,
80
- name: 'Sample Test Name',
81
- parent_tunnel: 'Mommy',
82
- prerun: prerun,
83
- priority: 0,
84
- public: 'team',
85
- record_logs: false,
86
- record_screenshots: false,
87
- record_video: false,
88
- screen_resolution: '10x10',
89
- selenium_version: '3.141.59',
90
- tags: tags,
91
- time_zone: 'San Francisco',
92
- tunnel_identifier: 'tunnelname',
93
- video_upload_on_pass: false
94
- }
95
-
96
- options = Options.new(**sauce_options)
97
-
98
- expect(options.avoid_proxy).to eq true
99
- expect(options.build).to eq 'Sample Build Name'
100
- expect(options.capture_performance).to eq true
101
- expect(options.chromedriver_version).to eq '71'
102
- expect(options.command_timeout).to eq 2
103
- expect(options.custom_data).to eq custom_data
104
- expect(options.extended_debugging).to eq true
105
- expect(options.idle_timeout).to eq 3
106
- expect(options.iedriver_version).to eq '3.141.0'
107
- expect(options.max_duration).to eq 300
108
- expect(options.name).to eq 'Sample Test Name'
109
- expect(options.parent_tunnel).to eq 'Mommy'
110
- expect(options.prerun).to eq prerun
111
- expect(options.priority).to eq 0
112
- expect(options.public).to eq 'team'
113
- expect(options.record_logs).to eq false
114
- expect(options.record_screenshots).to eq false
115
- expect(options.record_video).to eq false
116
- expect(options.screen_resolution).to eq '10x10'
117
- expect(options.selenium_version).to eq '3.141.59'
118
- expect(options.tags).to eq tags
119
- expect(options.time_zone).to eq 'San Francisco'
120
- expect(options.tunnel_identifier).to eq 'tunnelname'
121
- expect(options.video_upload_on_pass).to eq false
122
- end
123
-
124
- it 'accepts Selenium Capabilities and overrides default browser' do
125
- caps = Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true,
126
- page_load_strategy: 'eager')
127
- options = Options.new(selenium_options: caps)
128
-
129
- expect(options.browser_name).to eq 'firefox'
130
- expect(options.accept_insecure_certs).to eq true
131
- expect(options.page_load_strategy).to eq 'eager'
132
- end
133
-
134
- it 'accepts Selenium Options and overrides default browser' do
135
- browser_opts = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
136
- options = Options.new(selenium_options: browser_opts)
137
-
138
- expect(options.browser_name).to eq 'firefox'
139
- expect(options.selenium_options['moz:firefoxOptions']).to eq('args' => ['--foo'])
140
- end
141
-
142
- it 'accepts Selenium Capabilities and Options class instances' do
143
- caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true,
144
- page_load_strategy: 'eager')
145
- browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
146
- options = Options.new(selenium_options: [caps, browser_opts])
147
-
148
- expect(options.page_load_strategy).to eq 'eager'
149
- expect(options.accept_insecure_certs).to eq true
150
- expect(options.selenium_options['goog:chromeOptions']).to eq('args' => ['--foo'])
151
- end
152
-
153
- it 'accepts W3C, Sauce, Browser Options and Capabilities at the same time' do
154
- caps = Selenium::WebDriver::Remote::Capabilities.chrome(page_load_strategy: 'eager')
155
- browser_opts = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
156
-
157
- options = Options.new(browser_version: '77',
158
- accept_insecure_certs: true,
159
- command_timeout: 2,
160
- time_zone: 'Alaska',
161
- selenium_options: [caps, browser_opts])
162
-
163
- expect(options.browser_name).to eq 'firefox'
164
- expect(options.browser_version).to eq '77'
165
- expect(options.platform_name).to eq 'Windows 10'
166
- expect(options.accept_insecure_certs).to eq true
167
- expect(options.command_timeout).to eq 2
168
- expect(options.time_zone).to eq 'Alaska'
169
- expect(options.page_load_strategy).to eq 'eager'
170
-
171
- expect(options.selenium_options['moz:firefoxOptions']).to eq('args' => ['--foo'])
172
- end
173
-
174
- it 'creates a default build value' do
175
- options = Options.new
176
- expect(options.build).to eq 'TEMP BUILD: 11'
177
- end
178
-
179
- it 'raises ArgumentError if parameter is not recognized as valid' do
180
- expect { Options.new(foo: 'bar') }.to raise_exception(ArgumentError)
181
- end
182
- end
183
-
184
- describe '#accessors' do
185
- it 'parses w3c values' do
186
- proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
187
- timeouts = {implicit: 1,
188
- page_load: 59,
189
- script: 29}
190
-
191
- options = Options.new
192
-
193
- options.browser_name = 'firefox'
194
- options.browser_version = '7'
195
- options.platform_name = 'macOS 10.14'
196
- options.accept_insecure_certs = true
197
- options.page_load_strategy = 'eager'
198
- options.proxy = proxy
199
- options.set_window_rect = true
200
- options.unhandled_prompt_behavior = 'accept'
201
- options.strict_file_interactability = true
202
- options.timeouts = timeouts
203
-
204
- expect(options.browser_name).to eq 'firefox'
205
- expect(options.browser_version).to eq '7'
206
- expect(options.platform_name).to eq 'macOS 10.14'
207
- expect(options.accept_insecure_certs).to eq true
208
- expect(options.page_load_strategy).to eq 'eager'
209
- expect(options.proxy).to eq proxy
210
- expect(options.set_window_rect).to eq true
211
- expect(options.unhandled_prompt_behavior).to eq 'accept'
212
- expect(options.strict_file_interactability).to eq true
213
- expect(options.timeouts).to eq timeouts
214
- end
215
-
216
- it 'parses Sauce values' do
217
- custom_data = {foo: 'foo',
218
- bar: 'bar'}
219
- prerun = {executable: 'http://url.to/your/executable.exe',
220
- args: ['--silent', '-a', '-q'],
221
- background: false,
222
- timeout: 120}
223
- tags = %w[foo bar foobar]
224
-
225
- options = Options.new
226
-
227
- options.avoid_proxy = true
228
- options.build = 'Sample Build Name'
229
- options.capture_performance = true
230
- options.chromedriver_version = '71'
231
- options.command_timeout = 2
232
- options.custom_data = custom_data
233
- options.extended_debugging = true
234
- options.idle_timeout = 3
235
- options.iedriver_version = '3.141.0'
236
- options.max_duration = 300
237
- options.name = 'Sample Test Name'
238
- options.parent_tunnel = 'Mommy'
239
- options.prerun = prerun
240
- options.priority = 0
241
- options.public = 'team'
242
- options.record_logs = false
243
- options.record_screenshots = false
244
- options.record_video = false
245
- options.screen_resolution = '10x10'
246
- options.selenium_version = '3.141.59'
247
- options.tags = tags
248
- options.time_zone = 'San Francisco'
249
- options.tunnel_identifier = 'tunnelname'
250
- options.video_upload_on_pass = false
251
-
252
- expect(options.avoid_proxy).to eq true
253
- expect(options.build).to eq 'Sample Build Name'
254
- expect(options.capture_performance).to eq true
255
- expect(options.chromedriver_version).to eq '71'
256
- expect(options.command_timeout).to eq 2
257
- expect(options.custom_data).to eq custom_data
258
- expect(options.extended_debugging).to eq true
259
- expect(options.idle_timeout).to eq 3
260
- expect(options.iedriver_version).to eq '3.141.0'
261
- expect(options.max_duration).to eq 300
262
- expect(options.name).to eq 'Sample Test Name'
263
- expect(options.parent_tunnel).to eq 'Mommy'
264
- expect(options.prerun).to eq prerun
265
- expect(options.priority).to eq 0
266
- expect(options.public).to eq 'team'
267
- expect(options.record_logs).to eq false
268
- expect(options.record_screenshots).to eq false
269
- expect(options.record_video).to eq false
270
- expect(options.screen_resolution).to eq '10x10'
271
- expect(options.selenium_version).to eq '3.141.59'
272
- expect(options.tags).to eq tags
273
- expect(options.time_zone).to eq 'San Francisco'
274
- expect(options.tunnel_identifier).to eq 'tunnelname'
275
- expect(options.video_upload_on_pass).to eq false
276
- end
277
- end
278
-
279
- describe '#merge_capabilities' do
280
- it 'loads options from configuration' do
281
- timeouts = {implicit: 1,
282
- page_load: 59,
283
- script: 29}
284
- custom_data = {foo: 'foo',
285
- bar: 'bar'}
286
- prerun = {executable: 'http://url.to/your/executable.exe',
287
- args: ['--silent', '-a', '-q'],
288
- background: false,
289
- timeout: 120}
290
- tags = %w[foo bar foobar]
291
-
292
- options = Options.new
293
- yaml = YAML.load_file('spec/deprecated_options.yml')
294
- options.merge_capabilities(yaml['example_values'])
295
-
296
- expect(options.browser_name).to eq 'firefox'
297
- expect(options.browser_version).to eq '123'
298
- expect(options.platform_name).to eq 'Mac'
299
- expect(options.accept_insecure_certs).to eq true
300
- expect(options.page_load_strategy).to eq 'eager'
301
- expect(options.set_window_rect).to eq true
302
- expect(options.unhandled_prompt_behavior).to eq 'accept'
303
- expect(options.strict_file_interactability).to eq true
304
- expect(options.timeouts).to eq timeouts
305
- expect(options.avoid_proxy).to eq true
306
- expect(options.build).to eq 'Sample Build Name'
307
- expect(options.capture_performance).to eq true
308
- expect(options.chromedriver_version).to eq '71'
309
- expect(options.command_timeout).to eq 2
310
- expect(options.custom_data).to eq custom_data
311
- expect(options.extended_debugging).to eq true
312
- expect(options.idle_timeout).to eq 3
313
- expect(options.iedriver_version).to eq '3.141.0'
314
- expect(options.max_duration).to eq 300
315
- expect(options.name).to eq 'Sample Test Name'
316
- expect(options.parent_tunnel).to eq 'Mommy'
317
- expect(options.prerun).to eq prerun
318
- expect(options.priority).to eq 0
319
- expect(options.public).to eq 'team'
320
- expect(options.record_logs).to eq false
321
- expect(options.record_screenshots).to eq false
322
- expect(options.record_video).to eq false
323
- expect(options.screen_resolution).to eq '10x10'
324
- expect(options.selenium_version).to eq '3.141.59'
325
- expect(options.tags).to eq tags
326
- expect(options.time_zone).to eq 'San Francisco'
327
- expect(options.tunnel_identifier).to eq 'tunnelname'
328
- expect(options.video_upload_on_pass).to eq false
329
- end
330
-
331
- it 'raises exception if value not recognized' do
332
- options = Options.new
333
- yaml = YAML.load_file('spec/deprecated_options.yml')
334
-
335
- msg = 'foo is not a valid parameter for Options class'
336
- expect { options.merge_capabilities(yaml['invalid_option']) }.to raise_exception(ArgumentError, msg)
337
- end
338
- end
339
-
340
- describe '#capabilities' do
341
- it 'correctly generates capabilities for w3c values' do
342
- proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
343
- timeouts = {implicit: 1,
344
- page_load: 59,
345
- script: 29}
346
-
347
- options = Options.new(browser_name: 'firefox',
348
- platform_name: 'Mac',
349
- accept_insecure_certs: true,
350
- page_load_strategy: 'eager',
351
- proxy: proxy,
352
- set_window_rect: true,
353
- unhandled_prompt_behavior: 'accept',
354
- strict_file_interactability: true,
355
- timeouts: timeouts)
356
-
357
- proxy_type = Selenium::WebDriver::VERSION[0] == '3' ? 'MANUAL' : 'manual'
358
-
359
- expect(options.capabilities).to eq('browserName' => 'firefox',
360
- 'browserVersion' => 'latest',
361
- 'platformName' => 'Mac',
362
- 'acceptInsecureCerts' => true,
363
- 'pageLoadStrategy' => 'eager',
364
- 'proxy' => {'proxyType' => proxy_type, 'sslProxy' => 'foo'},
365
- 'setWindowRect' => true,
366
- 'unhandledPromptBehavior' => 'accept',
367
- 'strictFileInteractability' => true,
368
- 'timeouts' => {'implicit' => 1,
369
- 'pageLoad' => 59,
370
- 'script' => 29},
371
- 'sauce:options' => {'build' => 'TEMP BUILD: 11'})
190
+ describe '#accessors' do
191
+ it 'parses w3c values' do
192
+ proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
193
+ timeouts = {implicit: 1,
194
+ page_load: 59,
195
+ script: 29}
196
+
197
+ expect { @options = Options.new }.to have_deprecated_options_init
198
+
199
+ @options.browser_name = 'firefox'
200
+ @options.browser_version = '7'
201
+ @options.platform_name = 'macOS 10.14'
202
+ @options.accept_insecure_certs = true
203
+ @options.page_load_strategy = 'eager'
204
+ @options.proxy = proxy
205
+ @options.set_window_rect = true
206
+ @options.unhandled_prompt_behavior = 'accept'
207
+ @options.strict_file_interactability = true
208
+ @options.timeouts = timeouts
209
+
210
+ expect(@options.browser_name).to eq 'firefox'
211
+ expect(@options.browser_version).to eq '7'
212
+ expect(@options.platform_name).to eq 'macOS 10.14'
213
+ expect(@options.accept_insecure_certs).to eq true
214
+ expect(@options.page_load_strategy).to eq 'eager'
215
+ expect(@options.proxy).to eq proxy
216
+ expect(@options.set_window_rect).to eq true
217
+ expect(@options.unhandled_prompt_behavior).to eq 'accept'
218
+ expect(@options.strict_file_interactability).to eq true
219
+ expect(@options.timeouts).to eq timeouts
220
+ end
221
+
222
+ it 'parses Sauce values' do
223
+ custom_data = {foo: 'foo',
224
+ bar: 'bar'}
225
+ prerun = {executable: 'http://url.to/your/executable.exe',
226
+ args: ['--silent', '-a', '-q'],
227
+ background: false,
228
+ timeout: 120}
229
+ tags = %w[foo bar foobar]
230
+
231
+ expect { @options = Options.new }.to have_deprecated_options_init
232
+
233
+ @options.avoid_proxy = true
234
+ @options.build = 'Sample Build Name'
235
+ @options.capture_performance = true
236
+ @options.chromedriver_version = '71'
237
+ @options.command_timeout = 2
238
+ @options.custom_data = custom_data
239
+ @options.extended_debugging = true
240
+ @options.idle_timeout = 3
241
+ @options.iedriver_version = '3.141.0'
242
+ @options.max_duration = 300
243
+ @options.name = 'Sample Test Name'
244
+ @options.parent_tunnel = 'Mommy'
245
+ @options.prerun = prerun
246
+ @options.priority = 0
247
+ @options.public = 'team'
248
+ @options.record_logs = false
249
+ @options.record_screenshots = false
250
+ @options.record_video = false
251
+ @options.screen_resolution = '10x10'
252
+ @options.selenium_version = '3.141.59'
253
+ @options.tags = tags
254
+ @options.time_zone = 'San Francisco'
255
+ @options.tunnel_identifier = 'tunnelname'
256
+ @options.video_upload_on_pass = false
257
+
258
+ expect(@options.avoid_proxy).to eq true
259
+ expect(@options.build).to eq 'Sample Build Name'
260
+ expect(@options.capture_performance).to eq true
261
+ expect(@options.chromedriver_version).to eq '71'
262
+ expect(@options.command_timeout).to eq 2
263
+ expect(@options.custom_data).to eq custom_data
264
+ expect(@options.extended_debugging).to eq true
265
+ expect(@options.idle_timeout).to eq 3
266
+ expect(@options.iedriver_version).to eq '3.141.0'
267
+ expect(@options.max_duration).to eq 300
268
+ expect(@options.name).to eq 'Sample Test Name'
269
+ expect(@options.parent_tunnel).to eq 'Mommy'
270
+ expect(@options.prerun).to eq prerun
271
+ expect(@options.priority).to eq 0
272
+ expect(@options.public).to eq 'team'
273
+ expect(@options.record_logs).to eq false
274
+ expect(@options.record_screenshots).to eq false
275
+ expect(@options.record_video).to eq false
276
+ expect(@options.screen_resolution).to eq '10x10'
277
+ expect(@options.selenium_version).to eq '3.141.59'
278
+ expect(@options.tags).to eq tags
279
+ expect(@options.time_zone).to eq 'San Francisco'
280
+ expect(@options.tunnel_identifier).to eq 'tunnelname'
281
+ expect(@options.video_upload_on_pass).to eq false
282
+ end
372
283
  end
373
284
 
374
- it 'correctly generates capabilities for sauce values' do
375
- custom_data = {foo: 'foo',
376
- bar: 'bar'}
377
- prerun = {executable: 'http://url.to/your/executable.exe',
378
- args: ['--silent', '-a', '-q'],
379
- background: false,
380
- timeout: 120}
381
- tags = %w[foo bar foobar]
382
- sauce_options = {avoid_proxy: true,
383
- build: 'Sample Build Name',
384
- capture_performance: true,
385
- chromedriver_version: '71',
386
- command_timeout: 2,
387
- custom_data: custom_data,
388
- extended_debugging: true,
389
- idle_timeout: 3,
390
- iedriver_version: '3.141.0',
391
- max_duration: 300,
392
- name: 'Sample Test Name',
393
- parent_tunnel: 'Mommy',
394
- prerun: prerun,
395
- priority: 0,
396
- public: 'team',
397
- record_logs: false,
398
- record_screenshots: false,
399
- record_video: false,
400
- screen_resolution: '10x10',
401
- selenium_version: '3.141.59',
402
- tags: tags,
403
- time_zone: 'San Francisco',
404
- tunnel_identifier: 'tunnelname',
405
- video_upload_on_pass: false}
406
-
407
- options = Options.new(**sauce_options)
408
-
409
- prerun_caps = {'executable' => 'http://url.to/your/executable.exe',
410
- 'args' => ['--silent', '-a', '-q'],
411
- 'background' => false,
412
- 'timeout' => 120}
413
-
414
- expect(options.capabilities).to eq('browserName' => 'chrome',
415
- 'browserVersion' => 'latest',
416
- 'platformName' => 'Windows 10',
417
- 'sauce:options' => {'build' => 'Sample Build Name',
418
- 'avoidProxy' => true,
419
- 'capturePerformance' => true,
420
- 'chromedriverVersion' => '71',
421
- 'commandTimeout' => 2,
422
- 'customData' => {'foo' => 'foo',
423
- 'bar' => 'bar'},
424
- 'extendedDebugging' => true,
425
- 'idleTimeout' => 3,
426
- 'iedriverVersion' => '3.141.0',
427
- 'maxDuration' => 300,
428
- 'name' => 'Sample Test Name',
429
- 'parentTunnel' => 'Mommy',
430
- 'prerun' => prerun_caps,
431
- 'priority' => 0,
432
- 'public' => 'team',
433
- 'recordLogs' => false,
434
- 'recordScreenshots' => false,
435
- 'recordVideo' => false,
436
- 'screenResolution' => '10x10',
437
- 'seleniumVersion' => '3.141.59',
438
- 'tags' => %w[foo bar foobar],
439
- 'timeZone' => 'San Francisco',
440
- 'tunnelIdentifier' => 'tunnelname',
441
- 'videoUploadOnPass' => false})
285
+ describe '#merge_capabilities' do
286
+ it 'loads options from configuration' do
287
+ timeouts = {implicit: 1,
288
+ page_load: 59,
289
+ script: 29}
290
+ custom_data = {foo: 'foo',
291
+ bar: 'bar'}
292
+ prerun = {executable: 'http://url.to/your/executable.exe',
293
+ args: ['--silent', '-a', '-q'],
294
+ background: false,
295
+ timeout: 120}
296
+ tags = %w[foo bar foobar]
297
+
298
+ expect { @options = Options.new }.to have_deprecated_options_init
299
+ yaml = YAML.load_file('spec/deprecated_options.yml')
300
+ @options.merge_capabilities(yaml['example_values'])
301
+
302
+ expect(@options.browser_name).to eq 'firefox'
303
+ expect(@options.browser_version).to eq '123'
304
+ expect(@options.platform_name).to eq 'Mac'
305
+ expect(@options.accept_insecure_certs).to eq true
306
+ expect(@options.page_load_strategy).to eq 'eager'
307
+ expect(@options.set_window_rect).to eq true
308
+ expect(@options.unhandled_prompt_behavior).to eq 'accept'
309
+ expect(@options.strict_file_interactability).to eq true
310
+ expect(@options.timeouts).to eq timeouts
311
+ expect(@options.avoid_proxy).to eq true
312
+ expect(@options.build).to eq 'Sample Build Name'
313
+ expect(@options.capture_performance).to eq true
314
+ expect(@options.chromedriver_version).to eq '71'
315
+ expect(@options.command_timeout).to eq 2
316
+ expect(@options.custom_data).to eq custom_data
317
+ expect(@options.extended_debugging).to eq true
318
+ expect(@options.idle_timeout).to eq 3
319
+ expect(@options.iedriver_version).to eq '3.141.0'
320
+ expect(@options.max_duration).to eq 300
321
+ expect(@options.name).to eq 'Sample Test Name'
322
+ expect(@options.parent_tunnel).to eq 'Mommy'
323
+ expect(@options.prerun).to eq prerun
324
+ expect(@options.priority).to eq 0
325
+ expect(@options.public).to eq 'team'
326
+ expect(@options.record_logs).to eq false
327
+ expect(@options.record_screenshots).to eq false
328
+ expect(@options.record_video).to eq false
329
+ expect(@options.screen_resolution).to eq '10x10'
330
+ expect(@options.selenium_version).to eq '3.141.59'
331
+ expect(@options.tags).to eq tags
332
+ expect(@options.time_zone).to eq 'San Francisco'
333
+ expect(@options.tunnel_identifier).to eq 'tunnelname'
334
+ expect(@options.video_upload_on_pass).to eq false
335
+ end
336
+
337
+ it 'raises exception if value not recognized' do
338
+ expect { @options = Options.new }.to have_deprecated_options_init
339
+
340
+ yaml = YAML.load_file('spec/deprecated_options.yml')
341
+
342
+ msg = 'foo is not a valid parameter for Options class'
343
+ expect { @options.merge_capabilities(yaml['invalid_option']) }.to raise_exception(ArgumentError, msg)
344
+ end
442
345
  end
443
346
 
444
- it 'correctly generates capabilities for selenium object values' do
445
- caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true,
446
- page_load_strategy: 'eager')
447
- browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
448
- options = Options.new(selenium_options: [caps, browser_opts])
449
-
450
- jwp_defaults = {'cssSelectorsEnabled' => true,
451
- 'javascriptEnabled' => true,
452
- 'nativeEvents' => false,
453
- 'platform' => 'ANY',
454
- 'rotatable' => false,
455
- 'takesScreenshot' => false,
456
- 'version' => ''}
457
-
458
- expected_caps = {'browserName' => 'chrome',
459
- 'browserVersion' => 'latest',
460
- 'platformName' => 'Windows 10',
461
- 'acceptInsecureCerts' => true,
462
- 'pageLoadStrategy' => 'eager',
463
- 'sauce:options' => {'build' => 'TEMP BUILD: 11'},
464
- 'goog:chromeOptions' => {'args' => ['--foo']}}
465
-
466
- expected = Selenium::WebDriver::VERSION[0] == '3' ? jwp_defaults.merge(expected_caps) : expected_caps
467
-
468
- expect(options.capabilities).to eq expected
347
+ describe '#capabilities' do
348
+ it 'correctly generates capabilities for w3c values' do
349
+ proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
350
+ timeouts = {implicit: 1,
351
+ page_load: 59,
352
+ script: 29}
353
+
354
+ ClimateControl.modify(**BUILD_ENV) do
355
+ # expect {
356
+ @options = Options.new(browser_name: 'firefox',
357
+ platform_name: 'Mac',
358
+ accept_insecure_certs: true,
359
+ page_load_strategy: 'eager',
360
+ proxy: proxy,
361
+ set_window_rect: true,
362
+ unhandled_prompt_behavior: 'accept',
363
+ strict_file_interactability: true,
364
+ timeouts: timeouts)
365
+ # }.to have_deprecated_options_init
366
+ end
367
+
368
+ ClimateControl.modify(**SAUCE_ACCESS) do
369
+ expect {
370
+ @capabilities = @options.capabilities
371
+ }.to have_deprecated_timeouts
372
+ end
373
+
374
+ expect(@capabilities).to eq('browserName' => 'firefox',
375
+ 'browserVersion' => 'latest',
376
+ 'platformName' => 'Mac',
377
+ 'acceptInsecureCerts' => true,
378
+ 'pageLoadStrategy' => 'eager',
379
+ 'proxy' => {'proxyType' => 'manual', 'sslProxy' => 'foo'},
380
+ 'setWindowRect' => true,
381
+ 'unhandledPromptBehavior' => 'accept',
382
+ 'strictFileInteractability' => true,
383
+ 'timeouts' => {'implicit' => 1,
384
+ 'pageLoad' => 59,
385
+ 'script' => 29},
386
+ 'sauce:options' => {'build' => 'TEMP BUILD: 11',
387
+ 'username' => 'foo',
388
+ 'accessKey' => '123'})
389
+ end
390
+
391
+ it 'correctly generates capabilities for sauce values' do
392
+ custom_data = {foo: 'foo',
393
+ bar: 'bar'}
394
+ prerun = {executable: 'http://url.to/your/executable.exe',
395
+ args: ['--silent', '-a', '-q'],
396
+ background: false,
397
+ timeout: 120}
398
+ tags = %w[foo bar foobar]
399
+ sauce_options = {avoid_proxy: true,
400
+ build: 'Sample Build Name',
401
+ capture_performance: true,
402
+ chromedriver_version: '71',
403
+ command_timeout: 2,
404
+ custom_data: custom_data,
405
+ extended_debugging: true,
406
+ idle_timeout: 3,
407
+ iedriver_version: '3.141.0',
408
+ max_duration: 300,
409
+ name: 'Sample Test Name',
410
+ parent_tunnel: 'Mommy',
411
+ prerun: prerun,
412
+ priority: 0,
413
+ public: 'team',
414
+ record_logs: false,
415
+ record_screenshots: false,
416
+ record_video: false,
417
+ screen_resolution: '10x10',
418
+ selenium_version: '3.141.59',
419
+ tags: tags,
420
+ time_zone: 'San Francisco',
421
+ tunnel_identifier: 'tunnelname',
422
+ video_upload_on_pass: false}
423
+
424
+ ClimateControl.modify(**BUILD_ENV) do
425
+ expect { @options = Options.new(**sauce_options) }.to have_deprecated_options_init
426
+ end
427
+
428
+ prerun_caps = {'executable' => 'http://url.to/your/executable.exe',
429
+ 'args' => ['--silent', '-a', '-q'],
430
+ 'background' => false,
431
+ 'timeout' => 120}
432
+
433
+ ClimateControl.modify(**SAUCE_ACCESS) do
434
+ @capabilities = @options.capabilities
435
+ end
436
+
437
+ expect(@capabilities).to eq('browserName' => 'chrome',
438
+ 'browserVersion' => 'latest',
439
+ 'platformName' => 'Windows 10',
440
+ 'sauce:options' => {'build' => 'Sample Build Name',
441
+ 'avoidProxy' => true,
442
+ 'capturePerformance' => true,
443
+ 'chromedriverVersion' => '71',
444
+ 'commandTimeout' => 2,
445
+ 'customData' => {'foo' => 'foo',
446
+ 'bar' => 'bar'},
447
+ 'extendedDebugging' => true,
448
+ 'idleTimeout' => 3,
449
+ 'iedriverVersion' => '3.141.0',
450
+ 'maxDuration' => 300,
451
+ 'name' => 'Sample Test Name',
452
+ 'parentTunnel' => 'Mommy',
453
+ 'prerun' => prerun_caps,
454
+ 'priority' => 0,
455
+ 'public' => 'team',
456
+ 'recordLogs' => false,
457
+ 'recordScreenshots' => false,
458
+ 'recordVideo' => false,
459
+ 'screenResolution' => '10x10',
460
+ 'seleniumVersion' => '3.141.59',
461
+ 'tags' => %w[foo bar foobar],
462
+ 'timeZone' => 'San Francisco',
463
+ 'tunnelIdentifier' => 'tunnelname',
464
+ 'username' => 'foo',
465
+ 'accessKey' => '123',
466
+ 'videoUploadOnPass' => false})
467
+ end
468
+
469
+ it 'correctly generates capabilities for selenium object values' do
470
+ caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true,
471
+ page_load_strategy: 'eager')
472
+ browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
473
+
474
+ ClimateControl.modify(**BUILD_ENV) do
475
+ expect { @options = Options.new(selenium_options: [caps, browser_opts]) }.to have_deprecated_options_init
476
+ end
477
+
478
+ expected_caps = {'browserName' => 'chrome',
479
+ 'browserVersion' => 'latest',
480
+ 'platformName' => 'Windows 10',
481
+ 'acceptInsecureCerts' => true,
482
+ 'pageLoadStrategy' => 'eager',
483
+ 'sauce:options' => {'build' => 'TEMP BUILD: 11',
484
+ 'username' => 'foo',
485
+ 'accessKey' => '123'},
486
+ 'goog:chromeOptions' => {'args' => ['--foo']}}
487
+
488
+ ClimateControl.modify(**SAUCE_ACCESS) do
489
+ expect(@options.capabilities).to eq expected_caps
490
+ end
491
+ end
469
492
  end
470
493
  end
471
494
  end