watir 7.2.0 → 7.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/.github/workflows/chrome.yml +1 -1
- data/.github/workflows/edge.yml +1 -1
- data/.github/workflows/firefox.yml +1 -1
- data/.github/workflows/ie.yml +1 -1
- data/.github/workflows/safari.yml +1 -1
- data/.github/workflows/unit.yml +1 -1
- data/.rubocop.yml +25 -12
- data/.rubocop_todo.yml +8 -1
- data/CHANGES.md +6 -1
- data/LICENSE +2 -2
- data/lib/watir/capabilities.rb +1 -1
- data/lib/watir/locators/anchor/selector_builder.rb +3 -0
- data/lib/watir/locators/element/matcher.rb +2 -1
- data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +2 -1
- data/lib/watir/locators/text_field/matcher.rb +0 -4
- data/lib/watir/version.rb +1 -1
- data/spec/locator_spec_helper.rb +0 -8
- data/spec/unit/capabilities_spec.rb +553 -561
- data/spec/unit/element_locator_spec.rb +89 -78
- data/spec/unit/match_elements/button_spec.rb +69 -62
- data/spec/unit/match_elements/element_spec.rb +303 -309
- data/spec/unit/match_elements/text_field_spec.rb +76 -73
- data/spec/unit/selector_builder/anchor_spec.rb +39 -33
- data/spec/unit/selector_builder/button_spec.rb +209 -202
- data/spec/unit/selector_builder/cell_spec.rb +48 -42
- data/spec/unit/selector_builder/element_spec.rb +634 -627
- data/spec/unit/selector_builder/row_spec.rb +119 -113
- data/spec/unit/selector_builder/text_field_spec.rb +195 -188
- data/spec/unit/selector_builder/textarea_spec.rb +22 -14
- data/spec/unit/wait_spec.rb +85 -81
- data/spec/watirspec/adjacent_spec.rb +249 -247
- data/spec/watirspec/after_hooks_spec.rb +161 -159
- data/spec/watirspec/alert_spec.rb +61 -58
- data/spec/watirspec/browser_spec.rb +409 -409
- data/spec/watirspec/capabilities_spec.rb +89 -99
- data/spec/watirspec/cookies_spec.rb +120 -118
- data/spec/watirspec/drag_and_drop_spec.rb +26 -24
- data/spec/watirspec/element_hidden_spec.rb +66 -60
- data/spec/watirspec/elements/area_spec.rb +49 -47
- data/spec/watirspec/elements/areas_spec.rb +27 -25
- data/spec/watirspec/elements/button_spec.rb +253 -251
- data/spec/watirspec/elements/buttons_spec.rb +36 -34
- data/spec/watirspec/elements/checkbox_spec.rb +48 -36
- data/spec/watirspec/elements/checkboxes_spec.rb +29 -27
- data/spec/watirspec/elements/collections_spec.rb +126 -119
- data/spec/watirspec/elements/date_field_spec.rb +185 -183
- data/spec/watirspec/elements/date_fields_spec.rb +29 -27
- data/spec/watirspec/elements/date_time_field_spec.rb +197 -195
- data/spec/watirspec/elements/date_time_fields_spec.rb +30 -28
- data/spec/watirspec/elements/dd_spec.rb +87 -85
- data/spec/watirspec/elements/dds_spec.rb +27 -25
- data/spec/watirspec/elements/del_spec.rb +106 -104
- data/spec/watirspec/elements/dels_spec.rb +26 -24
- data/spec/watirspec/elements/div_spec.rb +225 -221
- data/spec/watirspec/elements/divs_spec.rb +37 -35
- data/spec/watirspec/elements/dl_spec.rb +110 -108
- data/spec/watirspec/elements/dls_spec.rb +28 -26
- data/spec/watirspec/elements/dt_spec.rb +86 -84
- data/spec/watirspec/elements/dts_spec.rb +27 -25
- data/spec/watirspec/elements/element_spec.rb +794 -775
- data/spec/watirspec/elements/elements_spec.rb +40 -38
- data/spec/watirspec/elements/em_spec.rb +62 -60
- data/spec/watirspec/elements/ems_spec.rb +28 -26
- data/spec/watirspec/elements/filefield_spec.rb +116 -114
- data/spec/watirspec/elements/filefields_spec.rb +28 -26
- data/spec/watirspec/elements/font_spec.rb +20 -18
- data/spec/watirspec/elements/form_spec.rb +51 -49
- data/spec/watirspec/elements/forms_spec.rb +29 -27
- data/spec/watirspec/elements/frame_spec.rb +89 -87
- data/spec/watirspec/elements/frames_spec.rb +27 -25
- data/spec/watirspec/elements/hidden_spec.rb +81 -79
- data/spec/watirspec/elements/hiddens_spec.rb +28 -26
- data/spec/watirspec/elements/hn_spec.rb +59 -57
- data/spec/watirspec/elements/hns_spec.rb +26 -24
- data/spec/watirspec/elements/iframe_spec.rb +195 -191
- data/spec/watirspec/elements/iframes_spec.rb +31 -29
- data/spec/watirspec/elements/image_spec.rb +148 -146
- data/spec/watirspec/elements/images_spec.rb +26 -24
- data/spec/watirspec/elements/input_spec.rb +9 -7
- data/spec/watirspec/elements/ins_spec.rb +106 -104
- data/spec/watirspec/elements/inses_spec.rb +26 -24
- data/spec/watirspec/elements/label_spec.rb +56 -54
- data/spec/watirspec/elements/labels_spec.rb +26 -24
- data/spec/watirspec/elements/li_spec.rb +76 -74
- data/spec/watirspec/elements/link_spec.rb +173 -177
- data/spec/watirspec/elements/links_spec.rb +45 -43
- data/spec/watirspec/elements/lis_spec.rb +27 -25
- data/spec/watirspec/elements/list_spec.rb +44 -42
- data/spec/watirspec/elements/map_spec.rb +57 -55
- data/spec/watirspec/elements/maps_spec.rb +27 -25
- data/spec/watirspec/elements/meta_spec.rb +16 -14
- data/spec/watirspec/elements/metas_spec.rb +26 -24
- data/spec/watirspec/elements/ol_spec.rb +56 -65
- data/spec/watirspec/elements/ols_spec.rb +26 -24
- data/spec/watirspec/elements/option_spec.rb +91 -89
- data/spec/watirspec/elements/p_spec.rb +81 -79
- data/spec/watirspec/elements/pre_spec.rb +77 -75
- data/spec/watirspec/elements/pres_spec.rb +26 -24
- data/spec/watirspec/elements/ps_spec.rb +26 -24
- data/spec/watirspec/elements/radio_spec.rb +251 -249
- data/spec/watirspec/elements/radios_spec.rb +28 -26
- data/spec/watirspec/elements/select_list_spec.rb +537 -526
- data/spec/watirspec/elements/select_lists_spec.rb +32 -30
- data/spec/watirspec/elements/span_spec.rb +112 -110
- data/spec/watirspec/elements/spans_spec.rb +26 -24
- data/spec/watirspec/elements/strong_spec.rb +58 -58
- data/spec/watirspec/elements/strongs_spec.rb +28 -26
- data/spec/watirspec/elements/table_spec.rb +192 -139
- data/spec/watirspec/elements/tables_spec.rb +28 -26
- data/spec/watirspec/elements/tbody_spec.rb +74 -72
- data/spec/watirspec/elements/tbodys_spec.rb +40 -38
- data/spec/watirspec/elements/td_spec.rb +66 -64
- data/spec/watirspec/elements/tds_spec.rb +41 -39
- data/spec/watirspec/elements/text_field_spec.rb +206 -204
- data/spec/watirspec/elements/text_fields_spec.rb +30 -28
- data/spec/watirspec/elements/textarea_spec.rb +20 -18
- data/spec/watirspec/elements/textareas_spec.rb +18 -16
- data/spec/watirspec/elements/tfoot_spec.rb +65 -63
- data/spec/watirspec/elements/tfoots_spec.rb +42 -40
- data/spec/watirspec/elements/thead_spec.rb +65 -63
- data/spec/watirspec/elements/theads_spec.rb +42 -40
- data/spec/watirspec/elements/tr_spec.rb +48 -46
- data/spec/watirspec/elements/trs_spec.rb +42 -40
- data/spec/watirspec/elements/ul_spec.rb +56 -54
- data/spec/watirspec/elements/uls_spec.rb +26 -24
- data/spec/watirspec/radio_set_spec.rb +269 -267
- data/spec/watirspec/screenshot_spec.rb +20 -18
- data/spec/watirspec/scroll_spec.rb +152 -148
- data/spec/watirspec/shadow_root_spec.rb +86 -83
- data/spec/watirspec/user_editable_spec.rb +200 -198
- data/spec/watirspec/wait_spec.rb +289 -295
- data/spec/watirspec/window_switching_spec.rb +422 -434
- data/spec/watirspec_helper.rb +1 -23
- data/watir.gemspec +5 -4
- metadata +44 -33
- data/spec/watirspec/attributes_spec.rb +0 -18
- data/spec/watirspec/elements/table_nesting_spec.rb +0 -51
- data/spec/watirspec/special_chars_spec.rb +0 -23
|
@@ -2,590 +2,578 @@
|
|
|
2
2
|
|
|
3
3
|
require 'watirspec_helper'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
after do
|
|
13
|
-
browser.windows.restore!
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe '#windows' do
|
|
17
|
-
it 'returns a WindowCollection' do
|
|
18
|
-
expect(browser.windows).to be_a(Watir::WindowCollection)
|
|
5
|
+
module Watir
|
|
6
|
+
describe Browser, exclude: {browser: :ie, reason: 'Cannot call #restore!'} do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
|
9
|
+
browser.a(id: 'open').click
|
|
10
|
+
browser.windows.wait_until(size: 2)
|
|
19
11
|
end
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
after do
|
|
14
|
+
browser.windows.restore!
|
|
23
15
|
end
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
describe '#windows' do
|
|
18
|
+
it 'returns a WindowCollection' do
|
|
19
|
+
expect(browser.windows).to be_a(WindowCollection)
|
|
20
|
+
end
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
it 'stores Window instances' do
|
|
23
|
+
expect(browser.windows(title: 'closeable window')).to all(be_a(Window))
|
|
24
|
+
end
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
26
|
+
it 'filters windows to match the given selector' do
|
|
27
|
+
expect(browser.windows(title: 'closeable window').size).to eq 1
|
|
28
|
+
end
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
end
|
|
30
|
+
it 'raises ArgumentError if the selector is invalid' do
|
|
31
|
+
expect { browser.windows(name: 'foo') }.to raise_error(ArgumentError)
|
|
32
|
+
end
|
|
42
33
|
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
it 'returns an empty array if no window matches the selector' do
|
|
35
|
+
expect(browser.windows(title: 'noop')).to be_empty
|
|
36
|
+
end
|
|
45
37
|
end
|
|
46
38
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
describe '#window' do
|
|
40
|
+
it 'finds window by :url' do
|
|
41
|
+
expect(browser.window(url: /closeable\.html/).use).to be_a(Window)
|
|
42
|
+
end
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
it 'finds window by :title' do
|
|
45
|
+
expect(browser.window(title: 'closeable window').use).to be_a(Window)
|
|
46
|
+
end
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
it 'finds window by :element' do
|
|
49
|
+
expect(browser.window(element: browser.a(id: 'close')).use).to be_a(Window)
|
|
50
|
+
end
|
|
58
51
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
it 'finds window by multiple values' do
|
|
53
|
+
expect(browser.window(title: 'closeable window', url: /closeable\.html/).use).to be_a(Window)
|
|
54
|
+
end
|
|
62
55
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
expect(original_window.url).to match(/window_switching\.html/)
|
|
67
|
-
end
|
|
56
|
+
it 'does not find incorrect handle' do
|
|
57
|
+
expect(browser.window(handle: 'bar')).not_to be_present
|
|
58
|
+
end
|
|
68
59
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'} do
|
|
72
|
-
browser.window(title: 'closeable window') do
|
|
73
|
-
link = browser.a(id: 'close')
|
|
74
|
-
expect(link).to exist
|
|
75
|
-
link.click
|
|
60
|
+
it 'returns the current window if no argument is given' do
|
|
61
|
+
expect(browser.window.url).to match(/window_switching\.html/)
|
|
76
62
|
end
|
|
77
63
|
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
it 'stores the reference to a window when no argument is given' do
|
|
65
|
+
original_window = browser.window
|
|
66
|
+
browser.window(title: 'closeable window').use
|
|
67
|
+
expect(original_window.url).to match(/window_switching\.html/)
|
|
68
|
+
end
|
|
80
69
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
it 'executes the given block in the window',
|
|
71
|
+
except: {browser: :safari,
|
|
72
|
+
reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'} do
|
|
73
|
+
browser.window(title: 'closeable window') do
|
|
74
|
+
link = browser.a(id: 'close')
|
|
75
|
+
expect(link).to exist
|
|
76
|
+
link.click
|
|
77
|
+
end
|
|
84
78
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
end
|
|
79
|
+
expect { browser.windows.wait_until(size: 1) }.not_to raise_error
|
|
80
|
+
end
|
|
88
81
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
end
|
|
82
|
+
it 'raises ArgumentError if the selector is invalid' do
|
|
83
|
+
expect { browser.window(name: 'foo') }.to raise_error(ArgumentError)
|
|
84
|
+
end
|
|
93
85
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
browser.window.close
|
|
98
|
-
browser.original_window.use
|
|
86
|
+
it 'raises a NoMatchingWindowFoundException error if no window matches the selector' do
|
|
87
|
+
expect { browser.window(title: 'noop').use }.to raise_no_matching_window_exception
|
|
88
|
+
end
|
|
99
89
|
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
it 'raises NoMatchingWindowFoundException error when attempting to use a window with an incorrect handle' do
|
|
91
|
+
expect { browser.window(handle: 'bar').use }.to raise_no_matching_window_exception
|
|
92
|
+
end
|
|
102
93
|
end
|
|
103
94
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
describe '#switch_window' do
|
|
96
|
+
it 'stays on the same window when matches single window' do
|
|
97
|
+
browser.switch_window
|
|
98
|
+
browser.window.close
|
|
99
|
+
browser.original_window.use
|
|
108
100
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
title = browser.title
|
|
102
|
+
expect { browser.window(title: title).use }.not_to raise_exception
|
|
103
|
+
end
|
|
112
104
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
it 'switches to second window' do
|
|
106
|
+
original_window = browser.window
|
|
107
|
+
browser.switch_window
|
|
108
|
+
new_window = browser.window
|
|
116
109
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
expect { browser.switch_window }.to raise_timeout_exception(message)
|
|
121
|
-
end
|
|
110
|
+
expect(original_window).not_to eq new_window
|
|
111
|
+
expect(browser.windows).to include(original_window, new_window)
|
|
112
|
+
end
|
|
122
113
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
end
|
|
114
|
+
it 'returns an instance of Window' do
|
|
115
|
+
expect(browser.switch_window).to be_a(Window)
|
|
116
|
+
end
|
|
127
117
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
browser.
|
|
132
|
-
|
|
133
|
-
}.to execute_when_satisfied(min: 1)
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
118
|
+
it 'times out if there is no second window' do
|
|
119
|
+
browser.windows.restore!
|
|
120
|
+
message = /waiting for true condition on (.*) title="window switching">$/
|
|
121
|
+
expect { browser.switch_window }.to raise_timeout_exception(message)
|
|
122
|
+
end
|
|
137
123
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
124
|
+
it 'provides previous window value to #original_window' do
|
|
125
|
+
browser.switch_window
|
|
126
|
+
expect(browser.original_window).not_to be_nil
|
|
127
|
+
end
|
|
142
128
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
129
|
+
it 'waits for second window' do
|
|
130
|
+
browser.windows.restore!
|
|
131
|
+
expect {
|
|
132
|
+
browser.a(id: 'delayed').click
|
|
133
|
+
browser.switch_window
|
|
134
|
+
}.to execute_when_satisfied(min: 1)
|
|
135
|
+
end
|
|
148
136
|
end
|
|
137
|
+
end
|
|
149
138
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
browser.
|
|
153
|
-
|
|
154
|
-
expect { browser.windows.wait_until(size: 3) }.to_not raise_timeout_exception
|
|
139
|
+
describe Window, exclude: {browser: :ie, reason: 'Cannot call #restore!'} do
|
|
140
|
+
after do
|
|
141
|
+
browser.windows.restore!
|
|
155
142
|
end
|
|
156
143
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
browser.
|
|
144
|
+
context 'when using multiple windows' do
|
|
145
|
+
before do
|
|
146
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
|
160
147
|
browser.a(id: 'open').click
|
|
161
|
-
browser.windows.wait_until(size:
|
|
148
|
+
browser.windows.wait_until(size: 2)
|
|
149
|
+
end
|
|
162
150
|
|
|
163
|
-
|
|
151
|
+
it 'allows actions on first window after opening second',
|
|
152
|
+
except: {browser: :safari, reason: 'Focus is on newly opened window instead of the first'} do
|
|
153
|
+
browser.a(id: 'open').click
|
|
164
154
|
|
|
165
|
-
expect { browser.windows.wait_until(size:
|
|
155
|
+
expect { browser.windows.wait_until(size: 3) }.not_to raise_timeout_exception
|
|
166
156
|
end
|
|
167
157
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
158
|
+
describe '#close' do
|
|
159
|
+
it 'closes a window' do
|
|
160
|
+
browser.window(title: 'window switching').use
|
|
161
|
+
browser.a(id: 'open').click
|
|
162
|
+
browser.windows.wait_until(size: 3)
|
|
173
163
|
|
|
174
|
-
|
|
164
|
+
described_class.new(browser, title: 'closeable window').close
|
|
175
165
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
end
|
|
166
|
+
expect { browser.windows.wait_until(size: 2) }.not_to raise_timeout_exception
|
|
167
|
+
end
|
|
179
168
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
end
|
|
169
|
+
it 'closes the current window',
|
|
170
|
+
except: {browser: :safari},
|
|
171
|
+
reason: 'Focus is on newly opened window instead of the first' do
|
|
172
|
+
browser.a(id: 'open').click
|
|
173
|
+
browser.windows.wait_until(size: 3)
|
|
186
174
|
|
|
187
|
-
|
|
188
|
-
it 'returns true if it is the current window' do
|
|
189
|
-
expect(Watir::Window.new(browser, title: browser.title)).to be_current
|
|
190
|
-
end
|
|
175
|
+
described_class.new(browser, title: 'closeable window').use.close
|
|
191
176
|
|
|
192
|
-
|
|
193
|
-
|
|
177
|
+
expect { browser.windows.wait_until(size: 2) }.not_to raise_timeout_exception
|
|
178
|
+
end
|
|
194
179
|
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
describe '#title' do
|
|
198
|
-
it 'returns the title of the window' do
|
|
199
|
-
browser.wait_while { |b| b.window(title: /^$/).exists? }
|
|
200
|
-
titles = browser.windows.map(&:title)
|
|
201
180
|
|
|
202
|
-
|
|
181
|
+
describe '#use' do
|
|
182
|
+
it 'switches to the window' do
|
|
183
|
+
described_class.new(browser, title: 'closeable window').use
|
|
184
|
+
expect(browser.title).to eq 'closeable window'
|
|
185
|
+
end
|
|
203
186
|
end
|
|
204
|
-
end
|
|
205
187
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
188
|
+
describe '#current?' do
|
|
189
|
+
it 'returns true if it is the current window' do
|
|
190
|
+
expect(described_class.new(browser, title: browser.title)).to be_current
|
|
191
|
+
end
|
|
209
192
|
|
|
210
|
-
|
|
193
|
+
it 'returns false if it is not the current window' do
|
|
194
|
+
expect(described_class.new(browser, title: 'closeable window')).not_to be_current
|
|
195
|
+
end
|
|
211
196
|
end
|
|
212
|
-
end
|
|
213
197
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
198
|
+
describe '#title' do
|
|
199
|
+
it 'returns the title of the window' do
|
|
200
|
+
browser.wait_while { |b| b.window(title: /^$/).exists? }
|
|
201
|
+
titles = browser.windows.map(&:title)
|
|
218
202
|
|
|
219
|
-
|
|
203
|
+
expect(titles).to include 'window switching', 'closeable window'
|
|
204
|
+
end
|
|
220
205
|
end
|
|
221
206
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
207
|
+
describe '#url' do
|
|
208
|
+
it 'returns the url of the window' do
|
|
209
|
+
urls = browser.windows.map(&:url)
|
|
225
210
|
|
|
226
|
-
|
|
211
|
+
expect(urls).to(include(/window_switching\.html/, /closeable\.html$/))
|
|
212
|
+
end
|
|
227
213
|
end
|
|
228
|
-
end
|
|
229
214
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
215
|
+
describe '#eql?' do
|
|
216
|
+
it 'knows when two windows are equal' do
|
|
217
|
+
win1 = described_class.new browser, {}
|
|
218
|
+
win2 = described_class.new browser, title: 'window switching'
|
|
234
219
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
end
|
|
220
|
+
expect(win1).to eq win2
|
|
221
|
+
end
|
|
238
222
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
223
|
+
it 'knows when two windows are not equal' do
|
|
224
|
+
win1 = described_class.new browser, title: 'closeable window'
|
|
225
|
+
win2 = described_class.new browser, title: 'window switching'
|
|
242
226
|
|
|
243
|
-
|
|
244
|
-
|
|
227
|
+
expect(win1).not_to eq win2
|
|
228
|
+
end
|
|
245
229
|
end
|
|
246
230
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
end
|
|
231
|
+
describe '#handle' do
|
|
232
|
+
it 'does not find if not matching' do
|
|
233
|
+
expect(browser.window(title: 'noop').handle).to be_nil
|
|
234
|
+
end
|
|
252
235
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
before do
|
|
257
|
-
@original_window = browser.window
|
|
258
|
-
browser.goto WatirSpec.url_for('window_switching.html')
|
|
259
|
-
browser.a(id: 'open').click
|
|
260
|
-
browser.windows.wait_until(size: 2)
|
|
261
|
-
@handles = browser.driver.window_handles
|
|
262
|
-
@closed_window = browser.window(title: 'closeable window').use
|
|
263
|
-
browser.a(id: 'close').click
|
|
264
|
-
browser.windows.wait_until(size: 1)
|
|
265
|
-
end
|
|
236
|
+
it 'finds window by :url' do
|
|
237
|
+
expect(browser.window(url: /closeable\.html/).handle).not_to be_nil
|
|
238
|
+
end
|
|
266
239
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
end
|
|
240
|
+
it 'finds window by :title' do
|
|
241
|
+
expect(browser.window(title: 'closeable window').handle).not_to be_nil
|
|
242
|
+
end
|
|
271
243
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
end
|
|
244
|
+
it 'finds window by :element' do
|
|
245
|
+
expect(browser.window(element: browser.a(id: 'close')).handle).not_to be_nil
|
|
246
|
+
end
|
|
276
247
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
248
|
+
it 'finds window by multiple values' do
|
|
249
|
+
expect(browser.window(url: /closeable\.html/, title: 'closeable window').handle).not_to be_nil
|
|
250
|
+
end
|
|
280
251
|
end
|
|
281
252
|
end
|
|
282
253
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
254
|
+
context 'with a closed window',
|
|
255
|
+
except: {browser: :safari,
|
|
256
|
+
reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'} do
|
|
257
|
+
before do
|
|
258
|
+
@original_window = browser.window
|
|
259
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
|
260
|
+
browser.a(id: 'open').click
|
|
261
|
+
browser.windows.wait_until(size: 2)
|
|
262
|
+
@handles = browser.driver.window_handles
|
|
263
|
+
@closed_window = browser.window(title: 'closeable window').use
|
|
264
|
+
browser.a(id: 'close').click
|
|
265
|
+
browser.windows.wait_until(size: 1)
|
|
286
266
|
end
|
|
287
|
-
end
|
|
288
267
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
268
|
+
describe '#exists?' do
|
|
269
|
+
it 'returns false if previously referenced window is closed' do
|
|
270
|
+
expect(@closed_window).not_to be_present
|
|
271
|
+
end
|
|
293
272
|
|
|
294
|
-
|
|
295
|
-
|
|
273
|
+
it 'returns false if closed window is referenced' do
|
|
274
|
+
expect(browser.window).not_to exist
|
|
275
|
+
end
|
|
296
276
|
end
|
|
297
|
-
end
|
|
298
277
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
expect { browser.a.text }.to raise_exception(Watir::Exception::NoMatchingWindowFoundException, msg)
|
|
305
|
-
end
|
|
278
|
+
describe '#current?' do
|
|
279
|
+
it 'returns false if the referenced window is closed' do
|
|
280
|
+
expect(@original_window).not_to be_current
|
|
281
|
+
end
|
|
282
|
+
end
|
|
306
283
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
284
|
+
describe '#eql?' do
|
|
285
|
+
it 'returns false when checking equivalence to a closed window' do
|
|
286
|
+
expect(browser.window).not_to eq @closed_widow
|
|
287
|
+
end
|
|
288
|
+
end
|
|
311
289
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
browser.a(id: 'open').click
|
|
316
|
-
browser.windows.wait_until(size: 2)
|
|
317
|
-
browser.window(title: 'closeable window').use
|
|
318
|
-
browser.a(id: 'close-delay').click
|
|
319
|
-
|
|
320
|
-
begin
|
|
321
|
-
module Watir
|
|
322
|
-
class Browser
|
|
323
|
-
alias title_old title
|
|
324
|
-
|
|
325
|
-
def title
|
|
326
|
-
sleep 0.5
|
|
327
|
-
title_old
|
|
328
|
-
end
|
|
329
|
-
end
|
|
290
|
+
describe '#use' do
|
|
291
|
+
it 'raises NoMatchingWindowFoundException error when attempting to use a referenced window that is closed' do
|
|
292
|
+
expect { @closed_window.use }.to raise_no_matching_window_exception
|
|
330
293
|
end
|
|
331
294
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
module Watir
|
|
335
|
-
class Browser
|
|
336
|
-
alias title title_old
|
|
337
|
-
end
|
|
295
|
+
it 'raises NoMatchingWindowFoundException error when attempting to use the current window if it is closed' do
|
|
296
|
+
expect { browser.window.use }.to raise_no_matching_window_exception
|
|
338
297
|
end
|
|
339
298
|
end
|
|
340
|
-
end
|
|
341
|
-
end
|
|
342
299
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
browser.windows.wait_until(size: 2)
|
|
350
|
-
browser.window(title: 'closeable window').use
|
|
351
|
-
browser.a(id: 'close').click
|
|
352
|
-
browser.windows.wait_until(size: 1)
|
|
353
|
-
end
|
|
354
|
-
|
|
355
|
-
describe '#present?' do
|
|
356
|
-
it 'should find window by url' do
|
|
357
|
-
expect(browser.window(url: /window_switching\.html/)).to be_present
|
|
300
|
+
it 'raises an exception when using an element on a closed window',
|
|
301
|
+
exclude: {browser: :firefox,
|
|
302
|
+
platform: :windows,
|
|
303
|
+
reason: 'https://github.com/mozilla/geckodriver/issues/1847'} do
|
|
304
|
+
msg = 'browser window was closed'
|
|
305
|
+
expect { browser.a.text }.to raise_exception(Exception::NoMatchingWindowFoundException, msg)
|
|
358
306
|
end
|
|
359
307
|
|
|
360
|
-
it '
|
|
361
|
-
expect
|
|
308
|
+
it 'raises an exception when locating a closed window' do
|
|
309
|
+
expect { browser.window(title: 'closeable window').use }.to raise_no_matching_window_exception
|
|
362
310
|
end
|
|
311
|
+
end
|
|
363
312
|
|
|
364
|
-
|
|
365
|
-
|
|
313
|
+
context 'with a closed window on a delay' do
|
|
314
|
+
it 'raises an exception when locating a window closed during lookup' do
|
|
315
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
|
316
|
+
browser.a(id: 'open').click
|
|
317
|
+
browser.windows.wait_until(size: 2)
|
|
318
|
+
browser.window(title: 'closeable window').use
|
|
319
|
+
browser.a(id: 'close-delay').click
|
|
320
|
+
allow(browser).to receive(:title).and_invoke(-> { sleep(0.5) && browser.wd.title })
|
|
321
|
+
|
|
322
|
+
expect { browser.window(title: 'closeable window').use }.to raise_no_matching_window_exception
|
|
366
323
|
end
|
|
367
324
|
end
|
|
368
325
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
326
|
+
context 'with current window closed',
|
|
327
|
+
except: {browser: :safari,
|
|
328
|
+
reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'} do
|
|
329
|
+
before do
|
|
330
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
|
331
|
+
browser.a(id: 'open').click
|
|
332
|
+
browser.windows.wait_until(size: 2)
|
|
333
|
+
browser.window(title: 'closeable window').use
|
|
334
|
+
browser.a(id: 'close').click
|
|
335
|
+
browser.windows.wait_until(size: 1)
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
describe '#present?' do
|
|
339
|
+
it 'finds window by url' do
|
|
340
|
+
expect(browser.window(url: /window_switching\.html/)).to be_present
|
|
374
341
|
end
|
|
375
342
|
|
|
376
|
-
it 'by title' do
|
|
377
|
-
browser.window(title: 'window switching').
|
|
378
|
-
expect(browser.url).to match(/window_switching\.html/)
|
|
343
|
+
it 'finds window by title' do
|
|
344
|
+
expect(browser.window(title: 'window switching')).to be_present
|
|
379
345
|
end
|
|
380
346
|
|
|
381
|
-
it 'by element' do
|
|
382
|
-
browser.window(element: browser.link(id: 'open')).
|
|
383
|
-
expect(browser.url).to match(/window_switching\.html/)
|
|
347
|
+
it 'finds window by element' do
|
|
348
|
+
expect(browser.window(element: browser.link(id: 'open'))).to be_present
|
|
384
349
|
end
|
|
385
350
|
end
|
|
386
351
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
352
|
+
describe '#use' do
|
|
353
|
+
context 'when switching windows without blocks' do
|
|
354
|
+
it 'by url' do
|
|
355
|
+
browser.window(url: /window_switching\.html/).use
|
|
356
|
+
expect(browser.title).to be == 'window switching'
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
it 'by title' do
|
|
360
|
+
browser.window(title: 'window switching').use
|
|
361
|
+
expect(browser.url).to match(/window_switching\.html/)
|
|
362
|
+
end
|
|
391
363
|
|
|
392
|
-
|
|
393
|
-
|
|
364
|
+
it 'by element' do
|
|
365
|
+
browser.window(element: browser.link(id: 'open')).use
|
|
366
|
+
expect(browser.url).to match(/window_switching\.html/)
|
|
367
|
+
end
|
|
394
368
|
end
|
|
395
369
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
370
|
+
context 'when switching windows with blocks' do
|
|
371
|
+
it 'by url' do
|
|
372
|
+
browser.window(url: /window_switching\.html/).use { expect(browser.title).to be == 'window switching' }
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
it 'by title' do
|
|
376
|
+
browser.window(title: 'window switching').use { expect(browser.url).to match(/window_switching\.html/) }
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
it 'by element' do
|
|
380
|
+
element = browser.link(id: 'open')
|
|
381
|
+
browser.window(element: element).use { expect(browser.url).to match(/window_switching\.html/) }
|
|
382
|
+
end
|
|
399
383
|
end
|
|
400
384
|
end
|
|
401
385
|
end
|
|
402
|
-
end
|
|
403
386
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
387
|
+
context 'when manipulating size and position', except: {headless: true} do
|
|
388
|
+
before(:all) do
|
|
389
|
+
maximized_size = browser.window.size
|
|
407
390
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
391
|
+
browser.window.resize_to(
|
|
392
|
+
maximized_size.width - 100,
|
|
393
|
+
maximized_size.height - 100
|
|
394
|
+
)
|
|
395
|
+
browser.wait_until { |b| b.window.size != maximized_size }
|
|
413
396
|
|
|
414
|
-
|
|
397
|
+
current_position = browser.window.position
|
|
415
398
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
399
|
+
browser.window.move_to(
|
|
400
|
+
current_position.x + 40,
|
|
401
|
+
current_position.y + 40
|
|
402
|
+
)
|
|
403
|
+
browser.wait_until { |b| b.window.position != current_position }
|
|
421
404
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
405
|
+
@initial_size = browser.window.size
|
|
406
|
+
@initial_position = browser.window.position
|
|
407
|
+
end
|
|
425
408
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
409
|
+
before do
|
|
410
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
|
411
|
+
end
|
|
429
412
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
413
|
+
after do
|
|
414
|
+
browser.window.resize_to @initial_size.width, @initial_size.height
|
|
415
|
+
browser.window.move_to @initial_position.x, @initial_position.y
|
|
416
|
+
end
|
|
434
417
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
418
|
+
it 'gets the size of the current window' do
|
|
419
|
+
expect(@initial_size.width).to eq browser.execute_script('return window.outerWidth;')
|
|
420
|
+
expect(@initial_size.height).to eq browser.execute_script('return window.outerHeight;')
|
|
421
|
+
end
|
|
439
422
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
423
|
+
it 'gets the position of the current window' do
|
|
424
|
+
expect(@initial_position.x).to eq browser.execute_script('return window.screenX;')
|
|
425
|
+
expect(@initial_position.y).to eq browser.execute_script('return window.screenY;')
|
|
426
|
+
end
|
|
444
427
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
428
|
+
it 'resizes the window' do
|
|
429
|
+
browser.window.resize_to(
|
|
430
|
+
@initial_size.width - 20,
|
|
431
|
+
@initial_size.height - 20
|
|
432
|
+
)
|
|
450
433
|
|
|
451
|
-
|
|
434
|
+
browser.wait_until { |b| b.window.size != @initial_size }
|
|
452
435
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
436
|
+
new_size = browser.window.size
|
|
437
|
+
expect(new_size.width).to eq @initial_size.width - 20
|
|
438
|
+
expect(new_size.height).to eq @initial_size.height - 20
|
|
439
|
+
end
|
|
457
440
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
441
|
+
it 'moves the window' do
|
|
442
|
+
browser.window.move_to(
|
|
443
|
+
@initial_position.x + 5,
|
|
444
|
+
@initial_position.y + 5
|
|
445
|
+
)
|
|
463
446
|
|
|
464
|
-
|
|
447
|
+
browser.wait_until { |b| b.window.position != @initial_position }
|
|
465
448
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
449
|
+
new_position = browser.window.position
|
|
450
|
+
expect(new_position.x).to eq @initial_position.x + 5
|
|
451
|
+
expect(new_position.y).to eq @initial_position.y + 5
|
|
452
|
+
end
|
|
470
453
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
454
|
+
it 'maximizes the window' do
|
|
455
|
+
browser.window.maximize
|
|
456
|
+
browser.wait_until { |b| b.window.size != @initial_size }
|
|
474
457
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
458
|
+
new_size = browser.window.size
|
|
459
|
+
expect(new_size.width).to be >= @initial_size.width
|
|
460
|
+
expect(new_size.height).to be > @initial_size.height
|
|
461
|
+
end
|
|
479
462
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
463
|
+
it 'makes the window full screen' do
|
|
464
|
+
browser.window.full_screen
|
|
465
|
+
browser.wait_until { |b| b.window.size != @initial_size }
|
|
483
466
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
467
|
+
new_size = browser.window.size
|
|
468
|
+
expect(new_size.width).to be >= @initial_size.width
|
|
469
|
+
expect(new_size.height).to be > @initial_size.height
|
|
470
|
+
end
|
|
488
471
|
|
|
489
|
-
|
|
490
|
-
|
|
472
|
+
it 'minimizes the window' do
|
|
473
|
+
expect(browser.execute_script('return document.visibilityState;')).to eq 'visible'
|
|
491
474
|
|
|
492
|
-
|
|
475
|
+
browser.window.minimize
|
|
493
476
|
|
|
494
|
-
|
|
477
|
+
browser.wait_until { |b| b.execute_script('return document.visibilityState;') != 'visible' }
|
|
495
478
|
|
|
496
|
-
|
|
497
|
-
|
|
479
|
+
expect(browser.execute_script('return document.visibilityState;')).to eq 'hidden'
|
|
480
|
+
browser.window.maximize
|
|
481
|
+
end
|
|
498
482
|
end
|
|
499
483
|
end
|
|
500
|
-
end
|
|
501
484
|
|
|
502
|
-
describe
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
485
|
+
describe WindowCollection, exclude: {browser: :ie, reason: 'Cannot call #restore!'} do
|
|
486
|
+
before do
|
|
487
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
|
488
|
+
browser.a(id: 'open').click
|
|
489
|
+
browser.windows.wait_until(size: 2)
|
|
490
|
+
end
|
|
508
491
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
492
|
+
after do
|
|
493
|
+
browser.windows.restore!
|
|
494
|
+
end
|
|
512
495
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
496
|
+
describe '#to_a' do
|
|
497
|
+
it 'raises exception' do
|
|
498
|
+
expect {
|
|
499
|
+
described_class.new(browser).to_a
|
|
500
|
+
}.to raise_exception(NoMethodError, 'indexing not reliable on WindowCollection')
|
|
501
|
+
end
|
|
502
|
+
end
|
|
518
503
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
504
|
+
describe '#new' do
|
|
505
|
+
it 'returns all windows by default' do
|
|
506
|
+
windows = described_class.new(browser)
|
|
522
507
|
|
|
523
|
-
|
|
524
|
-
|
|
508
|
+
expect(windows.size).to eq 2
|
|
509
|
+
end
|
|
525
510
|
|
|
526
|
-
|
|
527
|
-
|
|
511
|
+
it 'filters available windows by url' do
|
|
512
|
+
windows = described_class.new(browser, url: /closeable\.html/)
|
|
528
513
|
|
|
529
|
-
|
|
530
|
-
|
|
514
|
+
expect(windows.size).to eq 1
|
|
515
|
+
end
|
|
531
516
|
|
|
532
|
-
|
|
533
|
-
|
|
517
|
+
it 'filters available windows by title' do
|
|
518
|
+
windows = described_class.new(browser, title: /closeable/)
|
|
534
519
|
|
|
535
|
-
|
|
536
|
-
|
|
520
|
+
expect(windows.size).to eq 1
|
|
521
|
+
end
|
|
537
522
|
|
|
538
|
-
|
|
539
|
-
|
|
523
|
+
it 'filters available windows by element' do
|
|
524
|
+
windows = described_class.new(browser, element: browser.element(id: 'close'))
|
|
540
525
|
|
|
541
|
-
|
|
542
|
-
|
|
526
|
+
expect(windows.size).to eq 1
|
|
527
|
+
end
|
|
543
528
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
529
|
+
it 'raises ArgumentError if unrecognized locator' do
|
|
530
|
+
expect {
|
|
531
|
+
described_class.new(browser, foo: /closeable/)
|
|
532
|
+
}.to raise_error(ArgumentError)
|
|
533
|
+
end
|
|
548
534
|
end
|
|
549
|
-
end
|
|
550
535
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
536
|
+
describe '#size' do
|
|
537
|
+
it 'counts the number of matching windows' do
|
|
538
|
+
expect(described_class.new(browser).size).to eq 2
|
|
539
|
+
end
|
|
554
540
|
end
|
|
555
|
-
end
|
|
556
541
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
542
|
+
describe '#eq?' do
|
|
543
|
+
it 'compares the equivalence of window handles' do
|
|
544
|
+
windows1 = described_class.new(browser, title: //)
|
|
545
|
+
windows2 = described_class.new(browser, url: //)
|
|
561
546
|
|
|
562
|
-
|
|
547
|
+
expect(windows1).to eq windows2
|
|
548
|
+
end
|
|
563
549
|
end
|
|
564
|
-
end
|
|
565
550
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
551
|
+
describe '#reset!' do
|
|
552
|
+
it 'clears window list' do
|
|
553
|
+
wins = browser.windows
|
|
554
|
+
expect(wins.size).to eq 2
|
|
555
|
+
wins.reset!
|
|
556
|
+
expect(wins.instance_variable_get(:@window_list)).to be_nil
|
|
557
|
+
end
|
|
558
|
+
end
|
|
572
559
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
560
|
+
describe '#restore!' do
|
|
561
|
+
it 'when on other window',
|
|
562
|
+
except: {browser: :safari, reason: 'Focus is on newly opened window instead of the first'} do
|
|
563
|
+
browser.a(id: 'open').click
|
|
564
|
+
browser.windows.wait_until(size: 3)
|
|
565
|
+
browser.window(title: 'closeable window').use
|
|
579
566
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
567
|
+
browser.windows.restore!
|
|
568
|
+
expect(browser.windows.size).to eq 1
|
|
569
|
+
expect(browser.title).to eq 'window switching'
|
|
570
|
+
end
|
|
584
571
|
|
|
585
|
-
|
|
586
|
-
|
|
572
|
+
it 'when browser closed does not raise exception' do
|
|
573
|
+
browser.close
|
|
587
574
|
|
|
588
|
-
|
|
575
|
+
expect { browser.windows.restore! }.not_to raise_exception
|
|
576
|
+
end
|
|
589
577
|
end
|
|
590
578
|
end
|
|
591
579
|
end
|