watir 7.2.0 → 7.2.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/spec/watirspec/wait_spec.rb
CHANGED
@@ -2,350 +2,344 @@
|
|
2
2
|
|
3
3
|
require 'watirspec_helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
module Watir
|
6
|
+
describe Wait do
|
7
|
+
before do
|
8
|
+
browser.goto WatirSpec.url_for('wait.html')
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
describe '#default_timeout' do
|
12
|
+
context 'when no timeout is specified' do
|
13
|
+
it 'is used by Wait#until' do
|
14
|
+
expect { described_class.until { false } }.to wait_and_raise_timeout_exception(timeout: 1)
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
it 'is used by Wait#while' do
|
18
|
+
expect { described_class.while { true } }.to wait_and_raise_timeout_exception(timeout: 1)
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
it 'ensures all checks happen once even if time has expired' do
|
22
|
+
Watir.default_timeout = -1
|
23
|
+
expect { browser.link.click }.not_to raise_exception
|
24
|
+
ensure
|
25
|
+
Watir.default_timeout = 5
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe Watir::Element do
|
31
|
-
before do
|
32
|
-
browser.goto WatirSpec.url_for('wait.html')
|
33
|
-
end
|
34
29
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
it 'accepts self in block' do
|
42
|
-
element = browser.div(id: 'bar')
|
43
|
-
browser.a(id: 'show_bar').click
|
44
|
-
expect { element.wait_until { |el| el.text == 'bar' } }.to_not raise_exception
|
45
|
-
end
|
30
|
+
context 'when acting on Element' do
|
31
|
+
describe '#wait_until' do
|
32
|
+
it 'returns element for additional actions' do
|
33
|
+
element = browser.div(id: 'foo')
|
34
|
+
expect(element.wait_until(&:exist?)).to eq element
|
35
|
+
end
|
46
36
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
37
|
+
it 'accepts self in block' do
|
38
|
+
element = browser.div(id: 'bar')
|
39
|
+
browser.a(id: 'show_bar').click
|
40
|
+
expect { element.wait_until { |el| el.text == 'bar' } }.not_to raise_exception
|
41
|
+
end
|
51
42
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
it 'accepts any values in block' do
|
44
|
+
element = browser.div(id: 'bar')
|
45
|
+
expect { element.wait_until { true } }.not_to raise_exception
|
46
|
+
end
|
56
47
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
48
|
+
it 'accepts just a timeout parameter' do
|
49
|
+
element = browser.div(id: 'bar')
|
50
|
+
expect { element.wait_until(timeout: 0) { true } }.not_to raise_exception
|
51
|
+
end
|
61
52
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
53
|
+
it 'accepts just a message parameter' do
|
54
|
+
element = browser.div(id: 'bar')
|
55
|
+
expect { element.wait_until(message: 'no') { true } }.not_to raise_exception
|
56
|
+
end
|
66
57
|
|
67
|
-
|
68
|
-
|
58
|
+
it 'accepts just an interval parameter' do
|
59
|
+
element = browser.div(id: 'bar')
|
60
|
+
expect { element.wait_until(interval: 0.1) { true } }.not_to raise_exception
|
61
|
+
end
|
69
62
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
63
|
+
context 'when accepting keywords instead of block' do
|
64
|
+
before { browser.refresh }
|
65
|
+
|
66
|
+
it 'accepts text keyword' do
|
67
|
+
element = browser.div(id: 'bar')
|
68
|
+
browser.a(id: 'show_bar').click
|
69
|
+
expect { element.wait_until(text: 'bar') }.not_to raise_exception
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'accepts regular expression value' do
|
73
|
+
element = browser.div(id: 'bar')
|
74
|
+
browser.a(id: 'show_bar').click
|
75
|
+
expect { element.wait_until(style: /block/) }.not_to raise_exception
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'accepts multiple keywords' do
|
79
|
+
element = browser.div(id: 'bar')
|
80
|
+
browser.a(id: 'show_bar').click
|
81
|
+
expect { element.wait_until(text: 'bar', style: /block/) }.not_to raise_exception
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'accepts custom keyword' do
|
85
|
+
element = browser.div(id: 'bar')
|
86
|
+
browser.a(id: 'show_bar').click
|
87
|
+
expect { element.wait_until(custom: 'bar') }.not_to raise_exception
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'times out when single keyword not met' do
|
91
|
+
element = browser.div(id: 'bar')
|
92
|
+
expect { element.wait_until(id: 'foo') }.to raise_timeout_exception
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'times out when one of multiple keywords not met' do
|
96
|
+
element = browser.div(id: 'bar')
|
97
|
+
expect { element.wait_until(id: 'bar', text: 'foo') }.to raise_timeout_exception
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'times out when a custom keywords not met' do
|
101
|
+
element = browser.div(id: 'bar')
|
102
|
+
expect { element.wait_until(custom: 'foo') }.to raise_timeout_exception
|
103
|
+
end
|
104
|
+
end
|
74
105
|
end
|
75
106
|
|
76
|
-
|
77
|
-
element
|
78
|
-
|
79
|
-
|
80
|
-
|
107
|
+
describe '#wait_while' do
|
108
|
+
it 'returns element for additional actions' do
|
109
|
+
element = browser.div(id: 'foo')
|
110
|
+
browser.a(id: 'hide_foo').click
|
111
|
+
expect(element.wait_while(&:present?)).to eq element
|
112
|
+
end
|
81
113
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
end
|
114
|
+
it 'accepts any values in block' do
|
115
|
+
element = browser.div(id: 'foo')
|
116
|
+
expect { element.wait_while { false } }.not_to raise_exception
|
117
|
+
end
|
87
118
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
119
|
+
it 'accepts just a timeout parameter' do
|
120
|
+
element = browser.div(id: 'foo')
|
121
|
+
expect { element.wait_while(timeout: 0) { false } }.not_to raise_exception
|
122
|
+
end
|
93
123
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
124
|
+
it 'accepts just a message parameter' do
|
125
|
+
element = browser.div(id: 'foo')
|
126
|
+
expect { element.wait_while(message: 'no') { false } }.not_to raise_exception
|
127
|
+
end
|
98
128
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
129
|
+
it 'accepts just an interval parameter' do
|
130
|
+
element = browser.div(id: 'foo')
|
131
|
+
expect { element.wait_while(interval: 0.1) { false } }.not_to raise_exception
|
132
|
+
end
|
103
133
|
|
104
|
-
|
105
|
-
|
106
|
-
|
134
|
+
context 'when accepting keywords instead of block' do
|
135
|
+
it 'accepts text keyword', except: {browser: :safari,
|
136
|
+
reason: 'Safari does not recognize date type'} do
|
137
|
+
element = browser.div(id: 'foo')
|
138
|
+
browser.a(id: 'hide_foo').click
|
139
|
+
expect { element.wait_while(text: 'foo') }.not_to raise_exception
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'accepts regular expression value' do
|
143
|
+
element = browser.div(id: 'foo')
|
144
|
+
browser.a(id: 'hide_foo').click
|
145
|
+
expect { element.wait_while(style: /block/) }.not_to raise_exception
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'accepts multiple keywords' do
|
149
|
+
element = browser.div(id: 'foo')
|
150
|
+
browser.a(id: 'hide_foo').click
|
151
|
+
expect { element.wait_while(text: 'foo', style: /block/) }.not_to raise_exception
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'accepts custom attributes' do
|
155
|
+
element = browser.div(id: 'foo')
|
156
|
+
browser.a(id: 'hide_foo').click
|
157
|
+
expect { element.wait_while(custom: '') }.not_to raise_exception
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'accepts keywords and block' do
|
161
|
+
element = browser.div(id: 'foo')
|
162
|
+
browser.a(id: 'hide_foo').click
|
163
|
+
expect { element.wait_while(custom: '', &:present?) }.not_to raise_exception
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'browser accepts keywords' do
|
167
|
+
expect { browser.wait_until(title: 'wait test') }.not_to raise_exception
|
168
|
+
expect { browser.wait_until(title: 'wrong') }.to raise_timeout_exception
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'alert accepts keywords' do
|
172
|
+
browser.goto WatirSpec.url_for('alerts.html')
|
173
|
+
|
174
|
+
begin
|
175
|
+
browser.button(id: 'alert').click
|
176
|
+
expect { browser.alert.wait_until(text: 'ok') }.not_to raise_exception
|
177
|
+
expect { browser.alert.wait_until(text: 'not ok') }.to raise_timeout_exception
|
178
|
+
ensure
|
179
|
+
browser.alert.ok
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'window accepts keywords' do
|
184
|
+
expect { browser.window.wait_until(title: 'wait test') }.not_to raise_exception
|
185
|
+
expect { browser.window.wait_until(title: 'wrong') }.to raise_timeout_exception
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'times out when single keyword not met' do
|
189
|
+
element = browser.div(id: 'foo')
|
190
|
+
expect { element.wait_while(id: 'foo') }.to raise_timeout_exception
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'times out when one of multiple keywords not met' do
|
194
|
+
element = browser.div(id: 'foo')
|
195
|
+
browser.a(id: 'hide_foo').click
|
196
|
+
expect { element.wait_while(id: 'foo', style: /block/) }.to raise_timeout_exception
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'times out when one of custom keywords not met' do
|
200
|
+
element = browser.div(id: 'foo')
|
201
|
+
expect { element.wait_while(custom: '') }.to raise_timeout_exception
|
202
|
+
end
|
203
|
+
end
|
107
204
|
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe '#wait_while' do
|
112
|
-
it 'returns element for additional actions' do
|
113
|
-
element = browser.div(id: 'foo')
|
114
|
-
browser.a(id: 'hide_foo').click
|
115
|
-
expect(element.wait_while(&:present?)).to eq element
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'accepts any values in block' do
|
119
|
-
element = browser.div(id: 'foo')
|
120
|
-
expect { element.wait_while { false } }.to_not raise_exception
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'accepts just a timeout parameter' do
|
124
|
-
element = browser.div(id: 'foo')
|
125
|
-
expect { element.wait_while(timeout: 0) { false } }.to_not raise_exception
|
126
|
-
end
|
127
205
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
it 'accepts just an interval parameter' do
|
134
|
-
element = browser.div(id: 'foo')
|
135
|
-
expect { element.wait_while(interval: 0.1) { false } }.to_not raise_exception
|
136
|
-
end
|
137
|
-
|
138
|
-
context 'accepts keywords instead of block' do
|
139
|
-
it 'accepts text keyword', except: {browser: :safari,
|
140
|
-
reason: 'Safari does not recognize date type'} do
|
141
|
-
element = browser.div(id: 'foo')
|
142
|
-
browser.a(id: 'hide_foo').click
|
143
|
-
expect { element.wait_while(text: 'foo') }.to_not raise_exception
|
206
|
+
context 'when acting on an element that is never present' do
|
207
|
+
it 'raises exception after timing out' do
|
208
|
+
element = browser.link(id: 'not_there')
|
209
|
+
expect { element.click }.to wait_and_raise_unknown_object_exception
|
210
|
+
end
|
144
211
|
end
|
145
212
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
213
|
+
context 'when acting on an element that is already present' do
|
214
|
+
it 'does not wait' do
|
215
|
+
expect { browser.link.click }.to execute_when_satisfied(max: 1)
|
216
|
+
end
|
150
217
|
end
|
151
218
|
|
152
|
-
|
153
|
-
element
|
154
|
-
|
155
|
-
|
156
|
-
|
219
|
+
context 'when acting on an element that eventually becomes present' do
|
220
|
+
it 'waits until element is present and then takes action' do
|
221
|
+
expect {
|
222
|
+
browser.a(id: 'show_bar').click
|
223
|
+
browser.div(id: 'bar').click
|
224
|
+
}.to execute_when_satisfied(min: 1, max: 4)
|
225
|
+
expect(browser.div(id: 'bar').text).to eq 'changed'
|
226
|
+
end
|
157
227
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
228
|
+
it 'waits until text field present and then takes action' do
|
229
|
+
expect {
|
230
|
+
browser.a(id: 'show_textfield').click
|
231
|
+
browser.text_field(id: 'textfield').set 'Foo'
|
232
|
+
}.to execute_when_satisfied(min: 1, max: 4)
|
233
|
+
end
|
162
234
|
end
|
163
235
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
end
|
236
|
+
context 'when acting on a read only text field' do
|
237
|
+
it 'waits and raises read only exception if never becomes writable' do
|
238
|
+
expect { browser.text_field(id: 'writable').set 'foo' }.to wait_and_raise_object_read_only_exception
|
239
|
+
end
|
169
240
|
|
170
|
-
|
171
|
-
|
172
|
-
|
241
|
+
it 'waits until writable' do
|
242
|
+
expect {
|
243
|
+
browser.a(id: 'make-writable').click
|
244
|
+
browser.text_field(id: 'writable').set 'foo'
|
245
|
+
}.to execute_when_satisfied(min: 1, max: 4)
|
246
|
+
end
|
173
247
|
end
|
174
248
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
begin
|
179
|
-
browser.button(id: 'alert').click
|
180
|
-
expect { browser.alert.wait_until(text: 'ok') }.to_not raise_exception
|
181
|
-
expect { browser.alert.wait_until(text: 'not ok') }.to raise_timeout_exception
|
182
|
-
ensure
|
183
|
-
browser.alert.ok
|
249
|
+
context 'when acting on a disabled button' do
|
250
|
+
it 'waits and raises exception if it never becomes enabled' do
|
251
|
+
expect { browser.button(id: 'btn').click }.to wait_and_raise_object_disabled_exception
|
184
252
|
end
|
185
|
-
end
|
186
253
|
|
187
|
-
|
188
|
-
|
189
|
-
|
254
|
+
it 'waits until enabled' do
|
255
|
+
expect {
|
256
|
+
browser.a(id: 'enable_btn').click
|
257
|
+
browser.button(id: 'btn').click
|
258
|
+
}.to execute_when_satisfied(min: 1, max: 4)
|
259
|
+
end
|
190
260
|
end
|
191
261
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
262
|
+
context 'when acting on an element with a parent' do
|
263
|
+
it 'raises exception after timing out if parent never present' do
|
264
|
+
element = browser.link(id: 'not_there')
|
265
|
+
expect { element.element.click }.to wait_and_raise_unknown_object_exception
|
266
|
+
end
|
196
267
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
end
|
268
|
+
it 'raises exception after timing out when element from a collection whose parent is never present' do
|
269
|
+
element = browser.link(id: 'not_there')
|
270
|
+
expect { element.elements[2].click }.to wait_and_raise_unknown_object_exception
|
271
|
+
end
|
202
272
|
|
203
|
-
|
204
|
-
|
205
|
-
|
273
|
+
it 'does not wait for parent element to be present when querying child element' do
|
274
|
+
el = browser.element(id: 'not_there').element(id: 'doesnt_matter')
|
275
|
+
expect { el.present? }.to execute_when_satisfied(max: 1)
|
276
|
+
end
|
206
277
|
end
|
207
278
|
end
|
208
|
-
end
|
209
|
-
|
210
|
-
context 'when acting on an element that is never present' do
|
211
|
-
it 'raises exception after timing out' do
|
212
|
-
element = browser.link(id: 'not_there')
|
213
|
-
expect { element.click }.to wait_and_raise_unknown_object_exception
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
context 'when acting on an element that is already present' do
|
218
|
-
it 'does not wait' do
|
219
|
-
expect { browser.link.click }.to execute_when_satisfied(max: 1)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
context 'when acting on an element that eventually becomes present' do
|
224
|
-
it 'waits until element is present and then takes action' do
|
225
|
-
expect {
|
226
|
-
browser.a(id: 'show_bar').click
|
227
|
-
browser.div(id: 'bar').click
|
228
|
-
}.to execute_when_satisfied(min: 1)
|
229
|
-
expect(browser.div(id: 'bar').text).to eq 'changed'
|
230
|
-
end
|
231
|
-
|
232
|
-
it 'waits until text field present and then takes action' do
|
233
|
-
expect {
|
234
|
-
browser.a(id: 'show_textfield').click
|
235
|
-
browser.text_field(id: 'textfield').set 'Foo'
|
236
|
-
}.to execute_when_satisfied(min: 1)
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
context 'when acting on a read only text field' do
|
241
|
-
it 'waits and raises read only exception if never becomes writable' do
|
242
|
-
expect { browser.text_field(id: 'writable').set 'foo' }.to wait_and_raise_object_read_only_exception
|
243
|
-
end
|
244
|
-
|
245
|
-
it 'waits until writable' do
|
246
|
-
expect {
|
247
|
-
browser.a(id: 'make-writable').click
|
248
|
-
browser.text_field(id: 'writable').set 'foo'
|
249
|
-
}.to execute_when_satisfied(min: 1)
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
context 'when acting on a disabled button' do
|
254
|
-
it 'waits and raises exception if it never becomes enabled' do
|
255
|
-
expect { browser.button(id: 'btn').click }.to wait_and_raise_object_disabled_exception
|
256
|
-
end
|
257
|
-
|
258
|
-
it 'waits until enabled' do
|
259
|
-
expect {
|
260
|
-
browser.a(id: 'enable_btn').click
|
261
|
-
browser.button(id: 'btn').click
|
262
|
-
}.to execute_when_satisfied(min: 1)
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
context 'when acting on an element with a parent' do
|
267
|
-
it 'raises exception after timing out if parent never present' do
|
268
|
-
element = browser.link(id: 'not_there')
|
269
|
-
expect { element.element.click }.to wait_and_raise_unknown_object_exception
|
270
|
-
end
|
271
279
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
el = browser.element(id: 'not_there').element(id: 'doesnt_matter')
|
279
|
-
expect { el.present? }.to execute_when_satisfied(max: 1)
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
describe Watir::ElementCollection do
|
285
|
-
before do
|
286
|
-
browser.goto WatirSpec.url_for('wait.html')
|
287
|
-
end
|
280
|
+
context 'when acting on Element Collection' do
|
281
|
+
describe '#wait_until' do
|
282
|
+
it 'returns collection' do
|
283
|
+
elements = browser.divs
|
284
|
+
expect(elements.wait_until(&:exist?)).to eq elements
|
285
|
+
end
|
288
286
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
expect(elements.wait_until(&:exist?)).to eq elements
|
293
|
-
end
|
287
|
+
it 'times out when waiting for non-empty collection' do
|
288
|
+
expect { browser.divs.wait_until(&:empty?) }.to raise_timeout_exception
|
289
|
+
end
|
294
290
|
|
295
|
-
|
296
|
-
|
297
|
-
|
291
|
+
it 'provides matching collection when exists' do
|
292
|
+
expect {
|
293
|
+
browser.a(id: 'add_foobar').click
|
294
|
+
browser.divs(id: 'foobar').wait_until(&:exists?)
|
295
|
+
}.to execute_when_satisfied(min: 1)
|
296
|
+
end
|
298
297
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
298
|
+
it 'accepts self in block' do
|
299
|
+
expect {
|
300
|
+
browser.a(id: 'add_foobar').click
|
301
|
+
browser.divs.wait_until { |els| els.size == 7 }
|
302
|
+
}.to execute_when_satisfied(min: 1)
|
303
|
+
end
|
305
304
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
305
|
+
it 'accepts attributes to evaluate' do
|
306
|
+
expect {
|
307
|
+
browser.a(id: 'add_foobar').click
|
308
|
+
browser.divs.wait_until(size: 7)
|
309
|
+
}.to execute_when_satisfied(min: 1)
|
310
|
+
end
|
311
|
+
end
|
312
312
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
end
|
319
|
-
end
|
313
|
+
describe '#wait_while' do
|
314
|
+
it 'returns collection' do
|
315
|
+
elements = browser.divs
|
316
|
+
expect(elements.wait_while(&:empty?)).to eq elements
|
317
|
+
end
|
320
318
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
end
|
319
|
+
it 'times out when waiting for non-empty collection' do
|
320
|
+
elements = browser.divs
|
321
|
+
expect { elements.wait_while(&:exists?) }.to raise_timeout_exception
|
322
|
+
end
|
326
323
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
324
|
+
it 'provides matching collection when exists' do
|
325
|
+
expect {
|
326
|
+
browser.a(id: 'remove_foo').click
|
327
|
+
browser.divs(id: 'foo').wait_while(&:exists?)
|
328
|
+
}.to execute_when_satisfied(min: 1)
|
329
|
+
end
|
331
330
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
331
|
+
it 'accepts self in block' do
|
332
|
+
expect {
|
333
|
+
browser.a(id: 'add_foobar').click
|
334
|
+
browser.divs.wait_while { |els| els.size == 6 }
|
335
|
+
}.to execute_when_satisfied(min: 1)
|
336
|
+
end
|
337
|
+
end
|
338
338
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
}.to execute_when_satisfied(min: 1)
|
339
|
+
it 'waits for parent element to be present before locating' do
|
340
|
+
els = browser.element(id: /not|there/).elements(id: 'doesnt_matter')
|
341
|
+
expect { els.to_a }.to wait_and_raise_unknown_object_exception
|
342
|
+
end
|
344
343
|
end
|
345
344
|
end
|
346
|
-
|
347
|
-
it 'waits for parent element to be present before locating' do
|
348
|
-
els = browser.element(id: /not|there/).elements(id: 'doesnt_matter')
|
349
|
-
expect { els.to_a }.to wait_and_raise_unknown_object_exception
|
350
|
-
end
|
351
345
|
end
|