watir 7.0.0.beta1 → 7.0.0.beta2

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +7 -3
  3. data/.rubocop.yml +2 -7
  4. data/CHANGES.md +16 -0
  5. data/lib/watir/browser.rb +18 -4
  6. data/lib/watir/capabilities.rb +1 -1
  7. data/lib/watir/elements/element.rb +32 -3
  8. data/lib/watir/elements/font.rb +1 -0
  9. data/lib/watir/elements/iframe.rb +0 -1
  10. data/lib/watir/elements/radio.rb +2 -2
  11. data/lib/watir/elements/select.rb +63 -40
  12. data/lib/watir/has_window.rb +2 -0
  13. data/lib/watir/locators.rb +4 -0
  14. data/lib/watir/locators/element/matcher.rb +1 -1
  15. data/lib/watir/locators/element/selector_builder.rb +0 -3
  16. data/lib/watir/locators/option/matcher.rb +24 -0
  17. data/lib/watir/locators/option/selector_builder.rb +8 -0
  18. data/lib/watir/locators/option/selector_builder/xpath.rb +37 -0
  19. data/lib/watir/logger.rb +3 -74
  20. data/lib/watir/radio_set.rb +1 -0
  21. data/lib/watir/screenshot.rb +2 -8
  22. data/lib/watir/user_editable.rb +10 -3
  23. data/lib/watir/version.rb +1 -1
  24. data/lib/watir/window.rb +15 -4
  25. data/lib/watir/window_collection.rb +9 -0
  26. data/lib/watirspec.rb +4 -2
  27. data/lib/watirspec/guards.rb +1 -1
  28. data/lib/watirspec/server.rb +1 -1
  29. data/spec/spec_helper.rb +0 -10
  30. data/spec/unit/capabilities_spec.rb +1 -1
  31. data/spec/unit/match_elements/element_spec.rb +11 -0
  32. data/spec/watirspec/after_hooks_spec.rb +22 -45
  33. data/spec/watirspec/browser_spec.rb +185 -206
  34. data/spec/watirspec/cookies_spec.rb +47 -52
  35. data/spec/watirspec/drag_and_drop_spec.rb +5 -7
  36. data/spec/watirspec/elements/area_spec.rb +1 -5
  37. data/spec/watirspec/elements/button_spec.rb +4 -8
  38. data/spec/watirspec/elements/checkbox_spec.rb +2 -4
  39. data/spec/watirspec/elements/date_field_spec.rb +13 -16
  40. data/spec/watirspec/elements/date_time_field_spec.rb +14 -13
  41. data/spec/watirspec/elements/dd_spec.rb +3 -4
  42. data/spec/watirspec/elements/del_spec.rb +10 -12
  43. data/spec/watirspec/elements/div_spec.rb +41 -50
  44. data/spec/watirspec/elements/dl_spec.rb +4 -12
  45. data/spec/watirspec/elements/element_spec.rb +155 -89
  46. data/spec/watirspec/elements/elements_spec.rb +8 -9
  47. data/spec/watirspec/elements/filefield_spec.rb +5 -7
  48. data/spec/watirspec/elements/form_spec.rb +1 -1
  49. data/spec/watirspec/elements/forms_spec.rb +3 -5
  50. data/spec/watirspec/elements/frame_spec.rb +17 -22
  51. data/spec/watirspec/elements/iframe_spec.rb +21 -27
  52. data/spec/watirspec/elements/ins_spec.rb +10 -12
  53. data/spec/watirspec/elements/link_spec.rb +24 -26
  54. data/spec/watirspec/elements/links_spec.rb +8 -9
  55. data/spec/watirspec/elements/radio_spec.rb +11 -14
  56. data/spec/watirspec/elements/select_list_spec.rb +248 -117
  57. data/spec/watirspec/elements/span_spec.rb +10 -12
  58. data/spec/watirspec/elements/table_nesting_spec.rb +31 -34
  59. data/spec/watirspec/elements/table_spec.rb +11 -13
  60. data/spec/watirspec/elements/tbody_spec.rb +10 -12
  61. data/spec/watirspec/elements/td_spec.rb +4 -6
  62. data/spec/watirspec/elements/text_field_spec.rb +10 -12
  63. data/spec/watirspec/elements/tr_spec.rb +5 -7
  64. data/spec/watirspec/user_editable_spec.rb +26 -28
  65. data/spec/watirspec/wait_spec.rb +255 -258
  66. data/spec/watirspec/window_switching_spec.rb +199 -200
  67. data/spec/watirspec_helper.rb +34 -31
  68. metadata +5 -6
  69. data/spec/implementation_spec.rb +0 -24
  70. data/spec/unit/logger_spec.rb +0 -81
@@ -8,8 +8,7 @@ describe Watir::Browser do
8
8
  end
9
9
 
10
10
  after do
11
- browser.original_window.use
12
- browser.windows.reject(&:current?).each(&:close)
11
+ browser.windows.restore!
13
12
  end
14
13
 
15
14
  describe '#windows' do
@@ -65,16 +64,16 @@ describe Watir::Browser do
65
64
  expect(original_window.url).to match(/window_switching\.html/)
66
65
  end
67
66
 
68
- bug 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException', :safari do
69
- it 'it executes the given block in the window' do
70
- browser.window(title: 'closeable window') do
71
- link = browser.a(id: 'close')
72
- expect(link).to exist
73
- link.click
74
- end
75
-
76
- expect { browser.windows.wait_until(size: 1) }.to_not raise_error
67
+ it 'it executes the given block in the window',
68
+ except: {browser: :safari,
69
+ reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'} do
70
+ browser.window(title: 'closeable window') do
71
+ link = browser.a(id: 'close')
72
+ expect(link).to exist
73
+ link.click
77
74
  end
75
+
76
+ expect { browser.windows.wait_until(size: 1) }.to_not raise_error
78
77
  end
79
78
 
80
79
  it 'raises ArgumentError if the selector is invalid' do
@@ -97,7 +96,7 @@ describe Watir::Browser do
97
96
  browser.original_window.use
98
97
 
99
98
  title = browser.title
100
- expect { browser.window(title: title).use }.not_to raise_exception(TimeoutError)
99
+ expect { browser.window(title: title).use }.not_to raise_exception
101
100
  end
102
101
 
103
102
  it 'switches to second window' do
@@ -114,7 +113,7 @@ describe Watir::Browser do
114
113
  end
115
114
 
116
115
  it 'times out if there is no second window' do
117
- browser.windows.reject(&:current?).each(&:close)
116
+ browser.windows.restore!
118
117
  message = /waiting for true condition on (.*) title="window switching">$/
119
118
  expect { browser.switch_window }.to raise_timeout_exception(message)
120
119
  end
@@ -124,8 +123,8 @@ describe Watir::Browser do
124
123
  expect(browser.original_window).to_not be_nil
125
124
  end
126
125
 
127
- it 'waits for second window' do
128
- browser.windows.reject(&:current?).each(&:close)
126
+ it 'waits for second window', except: {browser: :ie} do
127
+ browser.windows.restore!
129
128
  expect {
130
129
  browser.a(id: 'delayed').click
131
130
  browser.switch_window
@@ -135,6 +134,10 @@ describe Watir::Browser do
135
134
  end
136
135
 
137
136
  describe Watir::Window do
137
+ after do
138
+ browser.windows.restore!
139
+ end
140
+
138
141
  context 'multiple windows' do
139
142
  before do
140
143
  browser.goto WatirSpec.url_for('window_switching.html')
@@ -142,41 +145,33 @@ describe Watir::Window do
142
145
  browser.windows.wait_until(size: 2)
143
146
  end
144
147
 
145
- after do
146
- browser.original_window.use
147
- browser.windows.reject(&:current?).each(&:close)
148
- end
149
-
150
- bug 'Focus is on newly opened window instead of the first', :safari do
151
- it 'allows actions on first window after opening second' do
152
- browser.a(id: 'open').click
148
+ it 'allows actions on first window after opening second',
149
+ except: {browser: %i[ie safari]}, reason: 'Focus is on newly opened window instead of the first' do
150
+ browser.a(id: 'open').click
153
151
 
154
- expect { browser.windows.wait_until(size: 3) }.to_not raise_timeout_exception
155
- end
152
+ expect { browser.windows.wait_until(size: 3) }.to_not raise_timeout_exception
156
153
  end
157
154
 
158
- not_compliant_on %i[firefox linux] do
159
- describe '#close' do
160
- it 'closes a window' do
161
- browser.window(title: 'window switching').use
162
- browser.a(id: 'open').click
163
- browser.windows.wait_until(size: 3)
155
+ describe '#close', except: {browser: :ie, reason: 'Click is not opening window'} do
156
+ it 'closes a window' do
157
+ browser.window(title: 'window switching').use
158
+ browser.a(id: 'open').click
159
+ browser.windows.wait_until(size: 3)
164
160
 
165
- Watir::Window.new(browser, title: 'closeable window').close
161
+ Watir::Window.new(browser, title: 'closeable window').close
166
162
 
167
- expect { browser.windows.wait_until(size: 2) }.to_not raise_timeout_exception
168
- end
163
+ expect { browser.windows.wait_until(size: 2) }.to_not raise_timeout_exception
164
+ end
169
165
 
170
- bug 'Focus is on newly opened window instead of the first', :safari do
171
- it 'closes the current window' do
172
- browser.a(id: 'open').click
173
- browser.windows.wait_until(size: 3)
166
+ it 'closes the current window',
167
+ except: {browser: %i[ie safari]},
168
+ reason: 'Focus is on newly opened window instead of the first' do
169
+ browser.a(id: 'open').click
170
+ browser.windows.wait_until(size: 3)
174
171
 
175
- Watir::Window.new(browser, title: 'closeable window').use.close
172
+ Watir::Window.new(browser, title: 'closeable window').use.close
176
173
 
177
- expect { browser.windows.wait_until(size: 2) }.to_not raise_timeout_exception
178
- end
179
- end
174
+ expect { browser.windows.wait_until(size: 2) }.to_not raise_timeout_exception
180
175
  end
181
176
  end
182
177
 
@@ -199,9 +194,9 @@ describe Watir::Window do
199
194
 
200
195
  describe '#title' do
201
196
  it 'returns the title of the window' do
197
+ browser.wait_while { |b| b.window(title: /^$/).exists? }
202
198
  titles = browser.windows.map(&:title)
203
199
 
204
- expect(titles.size).to eq 2
205
200
  expect(titles).to include 'window switching', 'closeable window'
206
201
  end
207
202
  end
@@ -210,7 +205,6 @@ describe Watir::Window do
210
205
  it 'returns the url of the window' do
211
206
  urls = browser.windows.map(&:url)
212
207
 
213
- expect(urls.size).to eq 2
214
208
  expect(urls).to(include(/window_switching\.html/, /closeable\.html$/))
215
209
  end
216
210
  end
@@ -254,77 +248,66 @@ describe Watir::Window do
254
248
  end
255
249
  end
256
250
 
257
- bug 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException', :safari do
258
- context 'with a closed window' do
259
- before do
260
- @original_window = browser.window
261
- browser.goto WatirSpec.url_for('window_switching.html')
262
- browser.a(id: 'open').click
263
- browser.windows.wait_until(size: 2)
264
- @handles = browser.driver.window_handles
265
- @closed_window = browser.window(title: 'closeable window').use
266
- browser.a(id: 'close').click
267
- browser.windows.wait_until(size: 1)
268
- end
251
+ context 'with a closed window',
252
+ except: {browser: :safari,
253
+ reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'} do
254
+ before do
255
+ @original_window = browser.window
256
+ browser.goto WatirSpec.url_for('window_switching.html')
257
+ browser.a(id: 'open').click
258
+ browser.windows.wait_until(size: 2)
259
+ @handles = browser.driver.window_handles
260
+ @closed_window = browser.window(title: 'closeable window').use
261
+ browser.a(id: 'close').click
262
+ browser.windows.wait_until(size: 1)
263
+ end
269
264
 
270
- after do
271
- browser.original_window.use
272
- browser.windows.reject(&:current?).each(&:close)
265
+ describe '#exists?' do
266
+ it 'returns false if previously referenced window is closed' do
267
+ expect(@closed_window).to_not be_present
273
268
  end
274
269
 
275
- describe '#exists?' do
276
- it 'returns false if previously referenced window is closed' do
277
- expect(@closed_window).to_not be_present
278
- end
279
-
280
- it 'returns false if closed window is referenced' do
281
- expect(browser.window).to_not exist
282
- end
270
+ it 'returns false if closed window is referenced' do
271
+ expect(browser.window).to_not exist
283
272
  end
273
+ end
284
274
 
285
- describe '#current?' do
286
- it 'returns false if the referenced window is closed' do
287
- expect(@original_window).to_not be_current
288
- end
275
+ describe '#current?' do
276
+ it 'returns false if the referenced window is closed' do
277
+ expect(@original_window).to_not be_current
289
278
  end
279
+ end
290
280
 
291
- describe '#eql?' do
292
- it 'should return false when checking equivalence to a closed window' do
293
- expect(browser.window).not_to eq @closed_widow
294
- end
281
+ describe '#eql?' do
282
+ it 'should return false when checking equivalence to a closed window' do
283
+ expect(browser.window).not_to eq @closed_widow
295
284
  end
285
+ end
296
286
 
297
- describe '#use' do
298
- it 'raises NoMatchingWindowFoundException error when attempting to use a referenced window that is closed' do
299
- expect { @closed_window.use }.to raise_no_matching_window_exception
300
- end
301
-
302
- bug 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException', :safari do
303
- it 'raises NoMatchingWindowFoundException error when attempting to use the current window if it is closed' do
304
- expect { browser.window.use }.to raise_no_matching_window_exception
305
- end
306
- end
287
+ describe '#use' do
288
+ it 'raises NoMatchingWindowFoundException error when attempting to use a referenced window that is closed' do
289
+ expect { @closed_window.use }.to raise_no_matching_window_exception
307
290
  end
308
291
 
309
- bug 'https://github.com/mozilla/geckodriver/issues/1847', :firefox do
310
- it 'raises an exception when using an element on a closed window' do
311
- msg = 'browser window was closed'
312
- expect { browser.a.text }.to raise_exception(Watir::Exception::NoMatchingWindowFoundException, msg)
313
- end
292
+ it 'raises NoMatchingWindowFoundException error when attempting to use the current window if it is closed' do
293
+ expect { browser.window.use }.to raise_no_matching_window_exception
314
294
  end
295
+ end
315
296
 
316
- it 'raises an exception when locating a closed window' do
317
- expect { browser.window(title: 'closeable window').use }.to raise_no_matching_window_exception
318
- end
297
+ it 'raises an exception when using an element on a closed window',
298
+ exclude: {browser: :firefox,
299
+ platform: :windows,
300
+ reason: 'https://github.com/mozilla/geckodriver/issues/1847'} do
301
+ msg = 'browser window was closed'
302
+ expect { browser.a.text }.to raise_exception(Watir::Exception::NoMatchingWindowFoundException, msg)
319
303
  end
320
- end
321
304
 
322
- context 'with a closed window on a delay' do
323
- after do
324
- browser.original_window.use
325
- browser.windows.reject(&:current?).each(&:close)
305
+ it 'raises an exception when locating a closed window' do
306
+ expect { browser.window(title: 'closeable window').use }.to raise_no_matching_window_exception
326
307
  end
308
+ end
327
309
 
310
+ context 'with a closed window on a delay' do
328
311
  it 'raises an exception when locating a window closed during lookup' do
329
312
  browser.goto WatirSpec.url_for('window_switching.html')
330
313
  browser.a(id: 'open').click
@@ -355,136 +338,127 @@ describe Watir::Window do
355
338
  end
356
339
  end
357
340
 
358
- bug 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException', :safari do
359
- context 'with current window closed' do
360
- before do
361
- browser.goto WatirSpec.url_for('window_switching.html')
362
- browser.a(id: 'open').click
363
- browser.windows.wait_until(size: 2)
364
- browser.window(title: 'closeable window').use
365
- browser.a(id: 'close').click
366
- browser.windows.wait_until(size: 1)
341
+ context 'with current window closed',
342
+ except: {browser: :safari,
343
+ reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'} do
344
+ before do
345
+ browser.goto WatirSpec.url_for('window_switching.html')
346
+ browser.a(id: 'open').click
347
+ browser.windows.wait_until(size: 2)
348
+ browser.window(title: 'closeable window').use
349
+ browser.a(id: 'close').click
350
+ browser.windows.wait_until(size: 1)
351
+ end
352
+
353
+ describe '#present?' do
354
+ it 'should find window by url' do
355
+ expect(browser.window(url: /window_switching\.html/)).to be_present
356
+ end
357
+
358
+ it 'should find window by title' do
359
+ expect(browser.window(title: 'window switching')).to be_present
367
360
  end
368
361
 
369
- after do
370
- browser.original_window.use
371
- browser.windows.reject(&:current?).each(&:close)
362
+ it 'should find window by element' do
363
+ expect(browser.window(element: browser.link(id: 'open'))).to be_present
372
364
  end
365
+ end
373
366
 
374
- describe '#present?' do
375
- it 'should find window by url' do
376
- expect(browser.window(url: /window_switching\.html/)).to be_present
367
+ describe '#use' do
368
+ context 'switching windows without blocks' do
369
+ it 'by url' do
370
+ browser.window(url: /window_switching\.html/).use
371
+ expect(browser.title).to be == 'window switching'
377
372
  end
378
373
 
379
- it 'should find window by title' do
380
- expect(browser.window(title: 'window switching')).to be_present
374
+ it 'by title' do
375
+ browser.window(title: 'window switching').use
376
+ expect(browser.url).to match(/window_switching\.html/)
381
377
  end
382
378
 
383
- it 'should find window by element' do
384
- expect(browser.window(element: browser.link(id: 'open'))).to be_present
379
+ it 'by element' do
380
+ browser.window(element: browser.link(id: 'open')).use
381
+ expect(browser.url).to match(/window_switching\.html/)
385
382
  end
386
383
  end
387
384
 
388
- describe '#use' do
389
- context 'switching windows without blocks' do
390
- it 'by url' do
391
- browser.window(url: /window_switching\.html/).use
392
- expect(browser.title).to be == 'window switching'
393
- end
394
-
395
- it 'by title' do
396
- browser.window(title: 'window switching').use
397
- expect(browser.url).to match(/window_switching\.html/)
398
- end
399
-
400
- it 'by element' do
401
- browser.window(element: browser.link(id: 'open')).use
402
- expect(browser.url).to match(/window_switching\.html/)
403
- end
385
+ context 'Switching windows with blocks' do
386
+ it 'by url' do
387
+ browser.window(url: /window_switching\.html/).use { expect(browser.title).to be == 'window switching' }
404
388
  end
405
389
 
406
- context 'Switching windows with blocks' do
407
- it 'by url' do
408
- browser.window(url: /window_switching\.html/).use { expect(browser.title).to be == 'window switching' }
409
- end
410
-
411
- it 'by title' do
412
- browser.window(title: 'window switching').use { expect(browser.url).to match(/window_switching\.html/) }
413
- end
390
+ it 'by title' do
391
+ browser.window(title: 'window switching').use { expect(browser.url).to match(/window_switching\.html/) }
392
+ end
414
393
 
415
- it 'by element' do
416
- element = browser.link(id: 'open')
417
- browser.window(element: element).use { expect(browser.url).to match(/window_switching\.html/) }
418
- end
394
+ it 'by element' do
395
+ element = browser.link(id: 'open')
396
+ browser.window(element: element).use { expect(browser.url).to match(/window_switching\.html/) }
419
397
  end
420
398
  end
421
399
  end
422
400
  end
423
401
 
424
- not_compliant_on :headless do
425
- context 'manipulating size and position' do
426
- before do
427
- browser.goto WatirSpec.url_for('window_switching.html')
428
- end
402
+ context 'manipulating size and position', except: {headless: true} do
403
+ before do
404
+ browser.goto WatirSpec.url_for('window_switching.html')
405
+ end
429
406
 
430
- it 'should get the size of the current window' do
431
- size = browser.window.size
407
+ it 'should get the size of the current window' do
408
+ size = browser.window.size
432
409
 
433
- expect(size.width).to eq browser.execute_script('return window.outerWidth;')
434
- expect(size.height).to eq browser.execute_script('return window.outerHeight;')
435
- end
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
+ end
436
413
 
437
- it 'should get the position of the current window' do
438
- pos = browser.window.position
414
+ it 'should get the position of the current window' do
415
+ pos = browser.window.position
439
416
 
440
- expect(pos.x).to eq browser.execute_script('return window.screenX;')
441
- expect(pos.y).to eq browser.execute_script('return window.screenY;')
442
- end
417
+ expect(pos.x).to eq browser.execute_script('return window.screenX;')
418
+ expect(pos.y).to eq browser.execute_script('return window.screenY;')
419
+ end
443
420
 
444
- it 'should resize the window' do
445
- initial_size = browser.window.size
446
- browser.window.resize_to(
447
- initial_size.width - 20,
448
- initial_size.height - 20
449
- )
421
+ it 'should resize the window' do
422
+ initial_size = browser.window.size
423
+ browser.window.resize_to(
424
+ initial_size.width - 20,
425
+ initial_size.height - 20
426
+ )
450
427
 
451
- new_size = browser.window.size
428
+ new_size = browser.window.size
452
429
 
453
- expect(new_size.width).to eq initial_size.width - 20
454
- expect(new_size.height).to eq initial_size.height - 20
455
- end
430
+ expect(new_size.width).to eq initial_size.width - 20
431
+ expect(new_size.height).to eq initial_size.height - 20
432
+ end
456
433
 
457
- it 'should move the window' do
458
- initial_pos = browser.window.position
434
+ it 'should move the window' do
435
+ initial_pos = browser.window.position
459
436
 
460
- browser.window.move_to(
461
- initial_pos.x + 2,
462
- initial_pos.y + 2
463
- )
437
+ browser.window.move_to(
438
+ initial_pos.x + 2,
439
+ initial_pos.y + 2
440
+ )
464
441
 
465
- new_pos = browser.window.position
466
- expect(new_pos.x).to eq initial_pos.x + 2
467
- expect(new_pos.y).to eq initial_pos.y + 2
468
- end
442
+ new_pos = browser.window.position
443
+ expect(new_pos.x).to eq initial_pos.x + 2
444
+ expect(new_pos.y).to eq initial_pos.y + 2
445
+ end
469
446
 
470
- compliant_on :window_manager do
471
- it 'should maximize the window' do
472
- initial_size = browser.window.size
473
- browser.window.resize_to(
474
- initial_size.width - 40,
475
- initial_size.height - 40
476
- )
477
- browser.wait_until { |b| b.window.size != initial_size }
478
- new_size = browser.window.size
479
-
480
- browser.window.maximize
481
- browser.wait_until { |b| b.window.size != new_size }
482
-
483
- final_size = browser.window.size
484
- expect(final_size.width).to be >= new_size.width
485
- expect(final_size.height).to be > (new_size.height)
486
- end
487
- end
447
+ it 'should maximize the window', except: {browser: :firefox, window_manager: false} do
448
+ initial_size = browser.window.size
449
+ browser.window.resize_to(
450
+ initial_size.width - 40,
451
+ initial_size.height - 40
452
+ )
453
+ browser.wait_until { |b| b.window.size != initial_size }
454
+ new_size = browser.window.size
455
+
456
+ browser.window.maximize
457
+ browser.wait_until { |b| b.window.size != new_size }
458
+
459
+ final_size = browser.window.size
460
+ expect(final_size.width).to be >= new_size.width
461
+ expect(final_size.height).to be > (new_size.height)
488
462
  end
489
463
  end
490
464
  end
@@ -497,8 +471,7 @@ describe Watir::WindowCollection do
497
471
  end
498
472
 
499
473
  after do
500
- browser.original_window.use
501
- browser.windows.reject(&:current?).each(&:close)
474
+ browser.windows.restore!
502
475
  end
503
476
 
504
477
  it '#to_a raises exception' do
@@ -553,4 +526,30 @@ describe Watir::WindowCollection do
553
526
  expect(windows1).to eq windows2
554
527
  end
555
528
  end
529
+
530
+ it '#reset!' do
531
+ wins = browser.windows
532
+ expect(wins.size).to eq 2
533
+ wins.reset!
534
+ expect(wins.instance_variable_get('@window_list')).to be_nil
535
+ end
536
+
537
+ describe '#restore!' do
538
+ it 'when on other window',
539
+ except: {browser: %i[ie safari], reason: 'Focus is on newly opened window instead of the first'} do
540
+ browser.a(id: 'open').click
541
+ browser.windows.wait_until(size: 3)
542
+ browser.window(title: 'closeable window').use
543
+
544
+ browser.windows.restore!
545
+ expect(browser.windows.size).to eq 1
546
+ expect(browser.title).to eq 'window switching'
547
+ end
548
+
549
+ it 'when browser closed does not raise exception' do
550
+ browser.close
551
+
552
+ expect { browser.windows.restore! }.not_to raise_exception
553
+ end
554
+ end
556
555
  end