watir 7.0.0.beta2 → 7.0.0

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.
@@ -39,16 +39,17 @@ describe Watir::Capabilities do
39
39
  # :listener
40
40
  # :service (Built from Hash)
41
41
  # :http_client (Generated or Built from Hash)
42
+ # :proxy (Built from Hash and added to :options)
42
43
  # :options (Generated or Built from Hash)
43
44
  # :capabilities (incompatible with options)
44
45
 
45
46
  supported_browsers.each do |browser_symbol|
46
- it 'just browser has client & capabilities not service' do
47
+ it 'just browser has client & options not service' do
47
48
  capabilities = Watir::Capabilities.new(browser_symbol)
48
49
 
49
50
  args = capabilities.to_args
50
51
  expect(args.last[:http_client]).to be_a Watir::HttpClient
51
- expect(args.last[:capabilities]).to be_a options_class(browser_symbol)
52
+ expect(args.last[:capabilities].first).to be_a options_class(browser_symbol)
52
53
  expect(args.last).not_to include(:service)
53
54
  end
54
55
 
@@ -58,7 +59,7 @@ describe Watir::Capabilities do
58
59
  args = capabilities.to_args
59
60
 
60
61
  expect(args.last[:http_client]).to be_a Watir::HttpClient
61
- expect(args.last[:capabilities]).to be_a options_class(browser_symbol)
62
+ expect(args.last[:capabilities].first).to be_a options_class(browser_symbol)
62
63
  expect(args.last).not_to include(:service)
63
64
  end
64
65
 
@@ -74,7 +75,7 @@ describe Watir::Capabilities do
74
75
  expect(args.last).not_to include(:service)
75
76
  end
76
77
 
77
- context 'service' do
78
+ describe 'service' do
78
79
  it 'uses provided service' do
79
80
  halt_service(browser_symbol)
80
81
 
@@ -106,7 +107,7 @@ describe Watir::Capabilities do
106
107
  end
107
108
  end
108
109
 
109
- context 'http_client' do
110
+ describe 'http_client' do
110
111
  it 'uses default HTTP Client' do
111
112
  capabilities = Watir::Capabilities.new(browser_symbol)
112
113
  args = capabilities.to_args
@@ -152,6 +153,114 @@ describe Watir::Capabilities do
152
153
  Watir::Capabilities.new(browser_symbol, capabilities: caps, options: opts)
153
154
  }.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
154
155
  end
156
+
157
+ describe 'timeout options' do
158
+ it 'accepts page load and script timeouts in seconds' do
159
+ options = {page_load_timeout: 11,
160
+ script_timeout: 12}
161
+ capabilities = Watir::Capabilities.new(browser_symbol, options: options)
162
+ args = capabilities.to_args
163
+ actual_options = args.last[:capabilities].first
164
+ expect(actual_options.timeouts[:page_load]).to eq 11_000
165
+ expect(actual_options.timeouts[:script]).to eq 12_000
166
+ end
167
+
168
+ it 'has deprecated timeouts key with page load warning' do
169
+ options = {timeouts: {page_load: 11}}
170
+ capabilities = Watir::Capabilities.new(browser_symbol, options: options)
171
+ msg = 'timeouts has been deprecated, use page_load_timeout (in seconds) directly instead'
172
+ expect {
173
+ capabilities.to_args
174
+ }.to have_deprecated_timeouts(msg)
175
+ end
176
+
177
+ it 'has deprecated timeouts key with script warning' do
178
+ options = {timeouts: {script: 11}}
179
+ expect {
180
+ capabilities = Watir::Capabilities.new(browser_symbol, options: options)
181
+ capabilities.to_args
182
+ }.to have_deprecated_timeouts('timeouts has been deprecated, use script_timeout (in seconds) directly instead')
183
+ end
184
+
185
+ it 'does not allow implicit wait timeout in timeouts hash' do
186
+ options = {timeouts: {implicit: 1}}
187
+ capabilities = Watir::Capabilities.new(browser_symbol, options: options)
188
+ expect {
189
+ capabilities.to_args
190
+ }.to raise_exception(ArgumentError, 'do not set implicit wait, Watir handles waiting automatically')
191
+ end
192
+ end
193
+
194
+ it 'unhandled prompt behavior defaults to ignore' do
195
+ capabilities = Watir::Capabilities.new(browser_symbol)
196
+ args = capabilities.to_args
197
+ actual_options = args.last[:capabilities].first
198
+ expect(actual_options.unhandled_prompt_behavior).to eq :ignore
199
+ end
200
+
201
+ it 'unhandled prompt behavior can be overridden' do
202
+ capabilities = Watir::Capabilities.new(browser_symbol, options: {unhandled_prompt_behavior: :accept_and_notify})
203
+ args = capabilities.to_args
204
+ actual_options = args.last[:capabilities].first
205
+ expect(actual_options.unhandled_prompt_behavior).to eq :accept_and_notify
206
+ end
207
+
208
+ describe 'proxy' do
209
+ it 'adds Selenium Proxy to empty Options' do
210
+ proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
211
+ capabilities = Watir::Capabilities.new(browser_symbol, proxy: proxy)
212
+ args = capabilities.to_args
213
+ proxy = args.last[:capabilities].first.proxy
214
+
215
+ expect(proxy).to be_a Selenium::WebDriver::Proxy
216
+ expect(proxy.type).to eq(:manual)
217
+ expect(proxy.http).to eq('127.0.0.1:8080')
218
+ expect(proxy.ssl).to eq('127.0.0.1:443')
219
+ end
220
+
221
+ it 'builds a Proxy from Hash for Options' do
222
+ proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
223
+ capabilities = Watir::Capabilities.new(browser_symbol, proxy: proxy)
224
+ args = capabilities.to_args
225
+ proxy = args.last[:capabilities].first.proxy
226
+
227
+ expect(proxy).to be_a Selenium::WebDriver::Proxy
228
+ expect(proxy.type).to eq(:manual)
229
+ expect(proxy.http).to eq('127.0.0.1:8080')
230
+ expect(proxy.ssl).to eq('127.0.0.1:443')
231
+ end
232
+
233
+ it 'builds a Proxy from Hash and adds to Options' do
234
+ proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
235
+ options = {unhandled_prompt_behavior: :accept,
236
+ page_load_strategy: :eager}
237
+
238
+ capabilities = Watir::Capabilities.new(browser_symbol, options: options, proxy: proxy)
239
+ args = capabilities.to_args
240
+ actual_options = args.last[:capabilities].first
241
+
242
+ expect(actual_options.proxy).to be_a Selenium::WebDriver::Proxy
243
+ expect(actual_options.proxy.type).to eq(:manual)
244
+ expect(actual_options.proxy.http).to eq('127.0.0.1:8080')
245
+ expect(actual_options.proxy.ssl).to eq('127.0.0.1:443')
246
+ expect(actual_options.unhandled_prompt_behavior).to eq :accept
247
+ expect(actual_options.page_load_strategy).to eq :eager
248
+ end
249
+ end
250
+
251
+ it 'errors on bad proxy key' do
252
+ proxy = {bad_key: 'foo'}
253
+ capabilities = Watir::Capabilities.new(browser_symbol, proxy: proxy)
254
+
255
+ expect { capabilities.to_args }.to raise_error(ArgumentError, /unknown option/)
256
+ end
257
+
258
+ it 'errors on bad proxy object' do
259
+ capabilities = Watir::Capabilities.new(browser_symbol, proxy: 7)
260
+ expect {
261
+ capabilities.to_args
262
+ }.to raise_exception(TypeError, '7 needs to be Selenium Proxy or Hash instance')
263
+ end
155
264
  end
156
265
 
157
266
  # Options:
@@ -159,6 +268,7 @@ describe Watir::Capabilities do
159
268
  # :service (Errors)
160
269
  # :listener
161
270
  # :http_client (Generated or Built from Hash)
271
+ # :proxy (Built from Hash and added to :options)
162
272
  # :options (Generated or Built from Hash)
163
273
  # :capabilities (incompatible with options)
164
274
 
@@ -167,11 +277,11 @@ describe Watir::Capabilities do
167
277
  capabilities = Watir::Capabilities.new(url: 'http://example.com')
168
278
  args = capabilities.to_args
169
279
  expect(args.first).to eq :remote
170
- actual_options = args.last[:capabilities]
280
+ actual_options = args.last[:capabilities].first
171
281
  expect(actual_options.browser_name).to eq 'chrome'
172
282
  end
173
283
 
174
- it 'browser name with url has capabilities and client but not service' do
284
+ it 'just url & browser name has capabilities and client but not service' do
175
285
  capabilities = Watir::Capabilities.new(:firefox,
176
286
  url: 'https://example.com/wd/hub/')
177
287
  args = capabilities.to_args
@@ -179,7 +289,7 @@ describe Watir::Capabilities do
179
289
  expect(args.last[:url]).to eq 'https://example.com/wd/hub/'
180
290
  expect(args.last[:http_client]).to be_a Watir::HttpClient
181
291
 
182
- expect(args.last[:capabilities]).to be_a Selenium::WebDriver::Firefox::Options
292
+ expect(args.last[:capabilities].first).to be_a Selenium::WebDriver::Firefox::Options
183
293
  expect(args.last).not_to include(:service)
184
294
  end
185
295
 
@@ -192,7 +302,7 @@ describe Watir::Capabilities do
192
302
  expect(args.last[:listener]).to eq listener
193
303
  end
194
304
 
195
- it 'browser name with url and http client object' do
305
+ it 'accepts http client object' do
196
306
  client = Watir::HttpClient.new
197
307
  capabilities = Watir::Capabilities.new(:chrome,
198
308
  url: 'https://example.com/wd/hub',
@@ -200,33 +310,61 @@ describe Watir::Capabilities do
200
310
  args = capabilities.to_args
201
311
  expect(args.first).to eq :remote
202
312
  expect(args.last[:http_client]).to eq client
203
- actual_options = args.last[:capabilities]
313
+ actual_options = args.last[:capabilities].first
204
314
  expect(actual_options.browser_name).to eq 'chrome'
205
315
  end
206
316
 
207
- it 'browser name with url and http client Hash' do
317
+ it 'accepts http client Hash' do
208
318
  capabilities = Watir::Capabilities.new(:chrome,
209
319
  url: 'https://example.com/wd/hub',
210
320
  http_client: {read_timeout: 30})
211
321
  args = capabilities.to_args
212
322
  expect(args.first).to eq :remote
213
323
  expect(args.last[:http_client].instance_variable_get('@read_timeout')).to eq 30
214
- actual_options = args.last[:capabilities]
324
+ actual_options = args.last[:capabilities].first
215
325
  expect(actual_options.browser_name).to eq 'chrome'
216
326
  end
217
327
 
218
- it 'browser name with url and options object' do
328
+ it 'accepts proxy object' do
329
+ proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
330
+ capabilities = Watir::Capabilities.new(:chrome,
331
+ url: 'https://example.com/wd/hub',
332
+ proxy: proxy)
333
+ args = capabilities.to_args
334
+ expect(args.first).to eq :remote
335
+ proxy = args.last[:capabilities].first.proxy
336
+ expect(proxy).to be_a Selenium::WebDriver::Proxy
337
+ expect(proxy.type).to eq(:manual)
338
+ expect(proxy.http).to eq('127.0.0.1:8080')
339
+ expect(proxy.ssl).to eq('127.0.0.1:443')
340
+ end
341
+
342
+ it 'accepts proxy Hash' do
343
+ proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
344
+ capabilities = Watir::Capabilities.new(:chrome,
345
+ url: 'https://example.com/wd/hub',
346
+ proxy: proxy)
347
+ args = capabilities.to_args
348
+ expect(args.first).to eq :remote
349
+ proxy = args.last[:capabilities].first.proxy
350
+ expect(proxy).to be_a Selenium::WebDriver::Proxy
351
+ expect(proxy.type).to eq(:manual)
352
+ expect(proxy.http).to eq('127.0.0.1:8080')
353
+ expect(proxy.ssl).to eq('127.0.0.1:443')
354
+ end
355
+
356
+ it 'accepts options object' do
219
357
  capabilities = Watir::Capabilities.new(:chrome,
220
358
  url: 'https://example.com/wd/hub',
221
359
  options: Selenium::WebDriver::Chrome::Options.new(args: ['--foo']))
222
360
  args = capabilities.to_args
223
361
  expect(args.first).to eq :remote
224
- actual_options = args.last[:capabilities]
362
+ actual_options = args.last[:capabilities].first
225
363
  expect(actual_options.browser_name).to eq 'chrome'
226
364
  expect(actual_options.args).to include('--foo')
227
365
  end
228
366
 
229
- it 'browser name with url and options hash' do
367
+ it 'accepts options hash' do
230
368
  options = {prefs: {foo: 'bar'}}
231
369
  capabilities = Watir::Capabilities.new(:chrome,
232
370
  url: 'http://example.com',
@@ -234,12 +372,12 @@ describe Watir::Capabilities do
234
372
  args = capabilities.to_args
235
373
  expect(args.first).to eq :remote
236
374
  expect(args.last[:url]).to eq 'http://example.com'
237
- actual_options = args.last[:capabilities]
375
+ actual_options = args.last[:capabilities].first
238
376
  expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
239
377
  expect(actual_options.prefs).to eq(foo: 'bar')
240
378
  end
241
379
 
242
- it 'browser name with url and capabilities' do
380
+ it 'accepts capabilities object' do
243
381
  caps = Watir::Capabilities.new(:chrome,
244
382
  url: 'https://example.com/wd/hub',
245
383
  capabilities: Selenium::WebDriver::Remote::Capabilities.chrome)
@@ -250,7 +388,7 @@ describe Watir::Capabilities do
250
388
  expect(actual_capabilities.browser_name).to eq 'chrome'
251
389
  end
252
390
 
253
- it 'browser name with http client & capabilities' do
391
+ it 'accepts http client & capabilities objects' do
254
392
  client = Watir::HttpClient.new
255
393
  caps = Watir::Capabilities.new(:chrome,
256
394
  url: 'https://example.com/wd/hub',
@@ -265,23 +403,30 @@ describe Watir::Capabilities do
265
403
  expect(actual_capabilities.browser_name).to eq 'chrome'
266
404
  end
267
405
 
268
- it 'browser name with http client & options object' do
406
+ it 'accepts http client & proxy & options objects' do
269
407
  client = Watir::HttpClient.new
408
+ proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
270
409
  options = Selenium::WebDriver::Chrome::Options.new(prefs: {foo: 'bar'})
271
410
  caps = Watir::Capabilities.new(:chrome,
272
411
  url: 'https://example.com/wd/hub',
412
+ proxy: proxy,
273
413
  options: options,
274
414
  http_client: client)
275
415
 
276
416
  args = caps.to_args
277
417
  expect(args.first).to eq :remote
278
418
  expect(args.last[:http_client]).to eq client
279
- actual_options = args.last[:capabilities]
419
+ actual_options = args.last[:capabilities].first
280
420
  expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
281
421
  expect(actual_options.prefs).to eq(foo: 'bar')
422
+ proxy = args.last[:capabilities].first.proxy
423
+ expect(proxy).to be_a Selenium::WebDriver::Proxy
424
+ expect(proxy.type).to eq(:manual)
425
+ expect(proxy.http).to eq('127.0.0.1:8080')
426
+ expect(proxy.ssl).to eq('127.0.0.1:443')
282
427
  end
283
428
 
284
- it 'browser name with options & capabilities' do
429
+ it 'raises exception when both options & capabilities defined' do
285
430
  options = {prefs: {foo: 'bar'}}
286
431
 
287
432
  expect {
@@ -297,7 +442,7 @@ describe Watir::Capabilities do
297
442
  headless: true,
298
443
  url: 'http://example.com')
299
444
  args = capabilities.to_args
300
- actual_options = args.last[:capabilities]
445
+ actual_options = args.last[:capabilities].first
301
446
  expect(actual_options.args).to include '--headless', '--disable-gpu'
302
447
  end
303
448
 
@@ -307,17 +452,22 @@ describe Watir::Capabilities do
307
452
  url: 'http://example.com')
308
453
  args = capabilities.to_args
309
454
 
310
- expect(args.last[:capabilities].args).to include '-headless'
455
+ expect(args.last[:capabilities].first.args).to include '-headless'
311
456
  end
312
457
 
313
- it 'allows sending to Browser Service Provider via options' do
458
+ it 'supports multiple vendor capabilities' do
459
+ sauce_options = {'sauce:options': {username: ENV['SAUCE_USERNAME'],
460
+ access_key: ENV['SAUCE_ACCESS_KEY']}}
461
+ other_options = {'other:options': {foo: 'bar'}}
462
+
314
463
  capabilities = Watir::Capabilities.new(:chrome,
315
- options: {'sauce:options': {username: ENV['SAUCE_USERNAME'],
316
- access_key: ENV['SAUCE_ACCESS_KEY']}},
464
+ options: sauce_options.merge(other_options),
317
465
  url: 'https://ondemand.us-west-1.saucelabs.com')
318
- args = capabilities.to_args
319
- actual_options = args.last[:capabilities].instance_variable_get('@options')
320
- expect(actual_options[:'sauce:options']).to include :username, :access_key
466
+
467
+ se_caps = capabilities.to_args.last[:capabilities]
468
+ expect(se_caps).to include(Selenium::WebDriver::Chrome::Options.new(unhandled_prompt_behavior: :ignore))
469
+ expect(se_caps).to include(Selenium::WebDriver::Remote::Capabilities.new(sauce_options))
470
+ expect(se_caps).to include(Selenium::WebDriver::Remote::Capabilities.new(other_options))
321
471
  end
322
472
  end
323
473
 
@@ -326,14 +476,14 @@ describe Watir::Capabilities do
326
476
  capabilities = Watir::Capabilities.new
327
477
  args = capabilities.to_args
328
478
  expect(args.last[:http_client]).to be_a Watir::HttpClient
329
- expect(args.last[:capabilities]).to be_a Selenium::WebDriver::Chrome::Options
479
+ expect(args.last[:capabilities].first).to be_a Selenium::WebDriver::Chrome::Options
330
480
  expect(args.last).not_to include(:service)
331
481
  end
332
482
 
333
483
  it 'sets headless by creating options' do
334
484
  capabilities = Watir::Capabilities.new(:chrome, headless: true)
335
485
  args = capabilities.to_args
336
- actual_options = args.last[:capabilities]
486
+ actual_options = args.last[:capabilities].first
337
487
  expect(actual_options.args).to include '--headless', '--disable-gpu'
338
488
  end
339
489
 
@@ -342,7 +492,7 @@ describe Watir::Capabilities do
342
492
  options: Selenium::WebDriver::Chrome::Options.new,
343
493
  headless: true)
344
494
  args = capabilities.to_args
345
- actual_options = args.last[:capabilities]
495
+ actual_options = args.last[:capabilities].first
346
496
  expect(actual_options.args).to include '--headless', '--disable-gpu'
347
497
  end
348
498
 
@@ -352,7 +502,7 @@ describe Watir::Capabilities do
352
502
  options: options,
353
503
  headless: true)
354
504
  args = capabilities.to_args
355
- actual_options = args.last[:capabilities]
505
+ actual_options = args.last[:capabilities].first
356
506
  expect(actual_options.args).to include '--headless', '--disable-gpu', '--foo'
357
507
  end
358
508
 
@@ -360,7 +510,7 @@ describe Watir::Capabilities do
360
510
  options = {args: %w[--foo --bar]}
361
511
  capabilities = Watir::Capabilities.new(:chrome, options: options)
362
512
  args = capabilities.to_args
363
- actual_options = args.last[:capabilities]
513
+ actual_options = args.last[:capabilities].first
364
514
  expect(actual_options).to be_a Selenium::WebDriver::Chrome::Options
365
515
  expect(actual_options.args).to include '--foo', '--bar'
366
516
  end
@@ -371,7 +521,7 @@ describe Watir::Capabilities do
371
521
  capabilities = Watir::Capabilities.new(:chrome,
372
522
  options: opts)
373
523
  args = capabilities.to_args
374
- actual_options = args.last[:capabilities]
524
+ actual_options = args.last[:capabilities].first
375
525
  expect(actual_options.page_load_strategy).to eq 'eager'
376
526
  expect(actual_options.args).to include '--foo', '--bar'
377
527
  end
@@ -384,7 +534,7 @@ describe Watir::Capabilities do
384
534
 
385
535
  capabilities = Watir::Capabilities.new(:firefox, options: options)
386
536
 
387
- actual_options = capabilities.to_args.last[:capabilities]
537
+ actual_options = capabilities.to_args.last[:capabilities].first
388
538
  expect(actual_options.args).to include '--foo'
389
539
  expect(actual_options.profile).to eq profile
390
540
  end
@@ -395,7 +545,7 @@ describe Watir::Capabilities do
395
545
 
396
546
  capabilities = Watir::Capabilities.new(:firefox, options: options)
397
547
 
398
- actual_options = capabilities.to_args.last[:capabilities]
548
+ actual_options = capabilities.to_args.last[:capabilities].first
399
549
  expect(actual_options.args).to include '--foo'
400
550
  expect(actual_options.profile).to eq profile
401
551
  end
@@ -403,7 +553,7 @@ describe Watir::Capabilities do
403
553
  it 'sets headless by creating options' do
404
554
  capabilities = Watir::Capabilities.new(:firefox, headless: true)
405
555
  args = capabilities.to_args
406
- actual_options = args.last[:capabilities]
556
+ actual_options = args.last[:capabilities].first
407
557
  expect(actual_options.args).to include '-headless'
408
558
  end
409
559
 
@@ -412,7 +562,7 @@ describe Watir::Capabilities do
412
562
  options: Selenium::WebDriver::Firefox::Options.new,
413
563
  headless: true)
414
564
  args = capabilities.to_args
415
- actual_options = args.last[:capabilities]
565
+ actual_options = args.last[:capabilities].first
416
566
  expect(actual_options.args).to include '-headless'
417
567
  end
418
568
 
@@ -422,7 +572,7 @@ describe Watir::Capabilities do
422
572
  options: options,
423
573
  headless: true)
424
574
  args = capabilities.to_args
425
- actual_options = args.last[:capabilities]
575
+ actual_options = args.last[:capabilities].first
426
576
  expect(actual_options.args).to include '-headless', '-foo'
427
577
  end
428
578
 
@@ -430,7 +580,7 @@ describe Watir::Capabilities do
430
580
  options = {args: %w[--foo --bar]}
431
581
  capabilities = Watir::Capabilities.new(:firefox, options: options)
432
582
  args = capabilities.to_args
433
- actual_options = args.last[:capabilities]
583
+ actual_options = args.last[:capabilities].first
434
584
  expect(actual_options).to be_a Selenium::WebDriver::Firefox::Options
435
585
  expect(actual_options.args).to include '--foo', '--bar'
436
586
  end
@@ -441,7 +591,7 @@ describe Watir::Capabilities do
441
591
  capabilities = Watir::Capabilities.new(:firefox,
442
592
  options: opts)
443
593
  args = capabilities.to_args
444
- actual_options = args.last[:capabilities]
594
+ actual_options = args.last[:capabilities].first
445
595
  expect(actual_options.args).to include '--foo', '--bar'
446
596
  expect(actual_options.page_load_strategy).to eq 'eager'
447
597
  end
@@ -460,7 +610,7 @@ describe Watir::Capabilities do
460
610
  options = {automatic_inspection: true}
461
611
  capabilities = Watir::Capabilities.new(:safari, options: options)
462
612
  args = capabilities.to_args
463
- actual_options = args.last[:capabilities]
613
+ actual_options = args.last[:capabilities].first
464
614
  expect(actual_options).to be_a Selenium::WebDriver::Safari::Options
465
615
  expect(actual_options.automatic_inspection).to eq true
466
616
  end
@@ -471,7 +621,7 @@ describe Watir::Capabilities do
471
621
  capabilities = Watir::Capabilities.new(:safari,
472
622
  options: opts)
473
623
  args = capabilities.to_args
474
- actual_options = args.last[:capabilities]
624
+ actual_options = args.last[:capabilities].first
475
625
  expect(actual_options.automatic_inspection).to eq true
476
626
  expect(actual_options.page_load_strategy).to eq 'eager'
477
627
  end
@@ -482,7 +632,7 @@ describe Watir::Capabilities do
482
632
  options = {args: %w[--foo --bar]}
483
633
  capabilities = Watir::Capabilities.new(:ie, options: options)
484
634
  args = capabilities.to_args
485
- actual_options = args.last[:capabilities]
635
+ actual_options = args.last[:capabilities].first
486
636
  expect(actual_options).to be_a Selenium::WebDriver::IE::Options
487
637
  expect(actual_options.args).to include '--foo', '--bar'
488
638
  end
@@ -491,7 +641,7 @@ describe Watir::Capabilities do
491
641
  options = {browser_attach_timeout: true}
492
642
  capabilities = Watir::Capabilities.new(:ie, options: options)
493
643
  args = capabilities.to_args
494
- actual_options = args.last[:capabilities]
644
+ actual_options = args.last[:capabilities].first
495
645
  expect(actual_options).to be_a Selenium::WebDriver::IE::Options
496
646
  expect(actual_options.options[:browser_attach_timeout]).to eq true
497
647
  end
@@ -502,7 +652,7 @@ describe Watir::Capabilities do
502
652
  capabilities = Watir::Capabilities.new(:ie,
503
653
  options: opts)
504
654
  args = capabilities.to_args
505
- actual_options = args.last[:capabilities]
655
+ actual_options = args.last[:capabilities].first
506
656
  expect(actual_options.args).to include '--foo'
507
657
  expect(actual_options.page_load_strategy).to eq 'eager'
508
658
  end
@@ -20,7 +20,7 @@ describe 'DateField' do
20
20
  end
21
21
 
22
22
  it 'returns true when using xpath',
23
- except: {browser: %i[ie safari], reason: 'Date type not recognized'} do
23
+ except: {browser: :ie, reason: 'Date type not recognized'} do
24
24
  expect(browser.date_field(xpath: "//input[@id='html5_date']")).to exist
25
25
  end
26
26
 
@@ -29,7 +29,7 @@ describe 'DateField' do
29
29
  end
30
30
 
31
31
  it 'respects date fields types',
32
- except: {browser: %i[ie safari], reason: 'Date type not recognized'} do
32
+ except: {browser: :ie, reason: 'Date type not recognized'} do
33
33
  expect(browser.date_field.type).to eq('date')
34
34
  end
35
35
 
@@ -78,7 +78,7 @@ describe 'DateField' do
78
78
 
79
79
  describe '#type' do
80
80
  it 'returns the type attribute if the date field exists',
81
- except: {browser: %i[ie safari], reason: 'Date type not recognized'} do
81
+ except: {browser: :ie, reason: 'Date type not recognized'} do
82
82
  expect(browser.date_field(id: 'html5_date').type).to eq 'date'
83
83
  end
84
84
 
@@ -20,8 +20,7 @@ describe 'DateTimeField' do
20
20
  end
21
21
 
22
22
  it 'returns true if the datetime-local element exists',
23
- except: [{browser: :firefox, reason: 'https://github.com/mozilla/geckodriver/issues/1469'},
24
- {browser: %i[ie safari], reason: 'Date type not recognized'}] do
23
+ except: {browser: :ie, reason: 'Date type not recognized'} do
25
24
  expect(browser.date_time_field(xpath: "//input[@id='html5_datetime-local']")).to exist
26
25
  end
27
26
 
@@ -30,8 +29,7 @@ describe 'DateTimeField' do
30
29
  end
31
30
 
32
31
  it 'respects date-time fields types',
33
- except: [{browser: :firefox, reason: 'https://github.com/mozilla/geckodriver/issues/1469'},
34
- {browser: %i[ie safari], reason: 'Date type not recognized'}] do
32
+ except: {browser: :ie, reason: 'Date type not recognized'} do
35
33
  expect(browser.date_time_field.type).to eq('datetime-local')
36
34
  end
37
35
 
@@ -80,8 +78,7 @@ describe 'DateTimeField' do
80
78
 
81
79
  describe '#type' do
82
80
  it 'returns the type attribute if the date-time field exists',
83
- except: [{browser: :firefox, reason: 'https://github.com/mozilla/geckodriver/issues/1469'},
84
- {browser: %i[ie safari], reason: 'Date type not recognized'}] do
81
+ except: {browser: :ie, reason: 'Date type not recognized'} do
85
82
  expect(browser.date_time_field(id: 'html5_datetime-local').type).to eq 'datetime-local'
86
83
  end
87
84
 
@@ -1,5 +1,5 @@
1
1
  if defined?(RSpec)
2
- DEPRECATION_WARNINGS = %i[use_capabilities].freeze
2
+ DEPRECATION_WARNINGS = %i[timeouts].freeze
3
3
 
4
4
  DEPRECATION_WARNINGS.each do |deprecation|
5
5
  RSpec::Matchers.define "have_deprecated_#{deprecation}" do
@@ -402,13 +402,16 @@ describe Watir::Window do
402
402
  context 'manipulating size and position', except: {headless: true} do
403
403
  before do
404
404
  browser.goto WatirSpec.url_for('window_switching.html')
405
+ @initial_size = browser.window.size
405
406
  end
406
407
 
407
- it 'should get the size of the current window' do
408
- size = browser.window.size
408
+ after do
409
+ browser.window.resize_to @initial_size.width, @initial_size.height
410
+ end
409
411
 
410
- expect(size.width).to eq browser.execute_script('return window.outerWidth;')
411
- expect(size.height).to eq browser.execute_script('return window.outerHeight;')
412
+ it 'should get the size of the current window' do
413
+ expect(@initial_size.width).to eq browser.execute_script('return window.outerWidth;')
414
+ expect(@initial_size.height).to eq browser.execute_script('return window.outerHeight;')
412
415
  end
413
416
 
414
417
  it 'should get the position of the current window' do
@@ -419,16 +422,15 @@ describe Watir::Window do
419
422
  end
420
423
 
421
424
  it 'should resize the window' do
422
- initial_size = browser.window.size
423
425
  browser.window.resize_to(
424
- initial_size.width - 20,
425
- initial_size.height - 20
426
+ @initial_size.width - 20,
427
+ @initial_size.height - 20
426
428
  )
427
429
 
428
430
  new_size = browser.window.size
429
431
 
430
- expect(new_size.width).to eq initial_size.width - 20
431
- expect(new_size.height).to eq initial_size.height - 20
432
+ expect(new_size.width).to eq @initial_size.width - 20
433
+ expect(new_size.height).to eq @initial_size.height - 20
432
434
  end
433
435
 
434
436
  it 'should move the window' do
@@ -445,12 +447,11 @@ describe Watir::Window do
445
447
  end
446
448
 
447
449
  it 'should maximize the window', except: {browser: :firefox, window_manager: false} do
448
- initial_size = browser.window.size
449
450
  browser.window.resize_to(
450
- initial_size.width - 40,
451
- initial_size.height - 40
451
+ @initial_size.width - 40,
452
+ @initial_size.height - 40
452
453
  )
453
- browser.wait_until { |b| b.window.size != initial_size }
454
+ browser.wait_until { |b| b.window.size != @initial_size }
454
455
  new_size = browser.window.size
455
456
 
456
457
  browser.window.maximize
@@ -458,7 +459,32 @@ describe Watir::Window do
458
459
 
459
460
  final_size = browser.window.size
460
461
  expect(final_size.width).to be >= new_size.width
461
- expect(final_size.height).to be > (new_size.height)
462
+ expect(final_size.height).to be > new_size.height
463
+ end
464
+
465
+ it 'should make the window full screen', except: {browser: :firefox, window_manager: false} do
466
+ browser.window.resize_to(
467
+ @initial_size.width - 40,
468
+ @initial_size.height - 40
469
+ )
470
+ new_size = browser.window.size
471
+
472
+ browser.window.full_screen
473
+ browser.wait_until { |b| b.window.size != new_size }
474
+
475
+ final_size = browser.window.size
476
+ expect(final_size.width).to be >= new_size.width
477
+ expect(final_size.height).to be > new_size.height
478
+ end
479
+
480
+ it 'should minimize the window', except: {window_manager: false} do
481
+ expect(browser.execute_script('return document.visibilityState;')).to eq 'visible'
482
+
483
+ browser.window.minimize
484
+
485
+ browser.wait_until { |b| b.execute_script('return document.visibilityState;') != 'visible' }
486
+
487
+ expect(browser.execute_script('return document.visibilityState;')).to eq 'hidden'
462
488
  end
463
489
  end
464
490
  end