watir 6.16.3 → 6.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/actions/enable-safari/action.yml +11 -0
- data/.github/actions/install-chrome/action.yml +11 -0
- data/.github/workflows/linux.yml +61 -0
- data/.github/workflows/mac.yml +55 -0
- data/.github/workflows/unit.yml +37 -0
- data/.github/workflows/windows.yml +39 -0
- data/.rubocop.yml +32 -107
- data/.rubocop_todo.yml +36 -0
- data/CHANGES.md +55 -0
- data/Gemfile +3 -1
- data/LICENSE +2 -2
- data/README.md +9 -10
- data/Rakefile +4 -4
- data/lib/watir-webdriver.rb +1 -1
- data/lib/watir.rb +3 -1
- data/lib/watir/adjacent.rb +8 -10
- data/lib/watir/after_hooks.rb +4 -4
- data/lib/watir/alert.rb +1 -0
- data/lib/watir/attribute_helper.rb +2 -0
- data/lib/watir/browser.rb +7 -3
- data/lib/watir/capabilities.rb +245 -97
- data/lib/watir/cookies.rb +3 -1
- data/lib/watir/element_collection.rb +21 -6
- data/lib/watir/elements/element.rb +66 -53
- data/lib/watir/elements/file_field.rb +1 -0
- data/lib/watir/elements/html_elements.rb +0 -1
- data/lib/watir/elements/iframe.rb +4 -3
- data/lib/watir/elements/link.rb +0 -9
- data/lib/watir/elements/radio.rb +1 -1
- data/lib/watir/elements/select.rb +22 -7
- data/lib/watir/generator/base/spec_extractor.rb +4 -4
- data/lib/watir/generator/html/generator.rb +1 -1
- data/lib/watir/has_window.rb +17 -15
- data/lib/watir/http_client.rb +17 -0
- data/lib/watir/js_execution.rb +3 -3
- data/lib/watir/js_snippets.rb +2 -2
- data/lib/watir/legacy_wait.rb +1 -1
- data/lib/watir/locators.rb +1 -3
- data/lib/watir/locators/element/locator.rb +12 -6
- data/lib/watir/locators/element/selector_builder.rb +12 -13
- data/lib/watir/locators/element/selector_builder/xpath.rb +40 -13
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +3 -1
- data/lib/watir/logger.rb +7 -20
- data/lib/watir/radio_set.rb +2 -2
- data/lib/watir/user_editable.rb +6 -2
- data/lib/watir/version.rb +1 -1
- data/lib/watir/wait.rb +2 -0
- data/lib/watir/wait/timer.rb +1 -1
- data/lib/watir/window.rb +8 -4
- data/lib/watir/window_collection.rb +114 -0
- data/lib/watirspec.rb +2 -1
- data/lib/watirspec/guards.rb +1 -1
- data/lib/watirspec/implementation.rb +3 -5
- data/lib/watirspec/rake_tasks.rb +2 -0
- data/lib/watirspec/runner.rb +6 -2
- data/lib/watirspec/server.rb +1 -1
- data/spec/spec_helper.rb +2 -7
- data/spec/unit/capabilities_spec.rb +1234 -18
- data/spec/unit/container_spec.rb +1 -1
- data/spec/unit/logger_spec.rb +5 -7
- data/spec/unit/match_elements/element_spec.rb +17 -15
- data/spec/unit/selector_builder/button_spec.rb +16 -15
- data/spec/unit/selector_builder/element_spec.rb +58 -9
- data/spec/unit/selector_builder/text_field_spec.rb +14 -14
- data/spec/unit/unit_helper.rb +2 -4
- data/spec/watirspec/after_hooks_spec.rb +58 -68
- data/spec/watirspec/alert_spec.rb +69 -79
- data/spec/watirspec/browser_spec.rb +51 -48
- data/spec/watirspec/cookies_spec.rb +52 -37
- data/spec/watirspec/drag_and_drop_spec.rb +14 -38
- data/spec/watirspec/elements/button_spec.rb +2 -0
- data/spec/watirspec/elements/buttons_spec.rb +1 -1
- data/spec/watirspec/elements/checkbox_spec.rb +8 -4
- data/spec/watirspec/elements/date_field_spec.rb +18 -9
- data/spec/watirspec/elements/date_time_field_spec.rb +3 -4
- data/spec/watirspec/elements/div_spec.rb +62 -54
- data/spec/watirspec/elements/element_spec.rb +73 -88
- data/spec/watirspec/elements/elements_spec.rb +12 -3
- data/spec/watirspec/elements/filefield_spec.rb +25 -50
- data/spec/watirspec/elements/form_spec.rb +6 -8
- data/spec/watirspec/elements/frame_spec.rb +10 -13
- data/spec/watirspec/elements/iframe_spec.rb +12 -9
- data/spec/watirspec/elements/iframes_spec.rb +2 -2
- data/spec/watirspec/elements/link_spec.rb +23 -12
- data/spec/watirspec/elements/links_spec.rb +11 -3
- data/spec/watirspec/elements/option_spec.rb +15 -17
- data/spec/watirspec/elements/select_list_spec.rb +222 -117
- data/spec/watirspec/elements/text_field_spec.rb +8 -4
- data/spec/watirspec/elements/tr_spec.rb +0 -9
- data/spec/watirspec/html/forms_with_input_elements.html +1 -0
- data/spec/watirspec/html/iframes.html +3 -0
- data/spec/watirspec/html/non_control_elements.html +4 -4
- data/spec/watirspec/html/right_click.html +12 -0
- data/spec/watirspec/html/wait.html +6 -6
- data/spec/watirspec/html/window_switching.html +10 -0
- data/spec/watirspec/legacy_wait_spec.rb +216 -0
- data/spec/watirspec/support/rspec_matchers.rb +33 -14
- data/spec/watirspec/user_editable_spec.rb +1 -1
- data/spec/watirspec/wait_spec.rb +257 -305
- data/spec/watirspec/window_switching_spec.rb +338 -211
- data/spec/watirspec_helper.rb +17 -20
- data/support/doctest_helper.rb +0 -2
- data/watir.gemspec +6 -7
- metadata +37 -26
- data/.travis.yml +0 -84
- data/appveyor.yml +0 -12
- data/lib/watir/elements/area.rb +0 -10
- data/spec/watirspec/relaxed_locate_spec.rb +0 -113
@@ -5,7 +5,7 @@ describe Watir::UserEditable do
|
|
5
5
|
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
bug 'incorrectly clears first', :safari do
|
9
9
|
describe '#append' do
|
10
10
|
it 'appends the text to the text field' do
|
11
11
|
browser.text_field(name: 'new_user_occupation').append(' Append This')
|
data/spec/watirspec/wait_spec.rb
CHANGED
@@ -1,400 +1,352 @@
|
|
1
1
|
require 'watirspec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# TODO: This is deprecated; remove in future version
|
9
|
-
not_compliant_on :relaxed_locate do
|
10
|
-
describe '#when_present' do
|
11
|
-
it 'invokes subsequent method calls when the element becomes present' do
|
12
|
-
browser.a(id: 'show_bar').click
|
13
|
-
|
14
|
-
bar = browser.div(id: 'bar')
|
15
|
-
bar.when_present(2).click
|
16
|
-
expect(bar.text).to eq 'changed'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'times out when given a block' do
|
20
|
-
expect { browser.div(id: 'bar').when_present(1) {} }.to raise_error(Watir::Wait::TimeoutError)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'times out when not given a block' do
|
24
|
-
locator = '(\{:id=>"bar", :tag_name=>"div"\}|\{:tag_name=>"div", :id=>"bar"\})'
|
25
|
-
msg = /^timed out after 1 seconds, waiting for #{locator} to become present$/
|
26
|
-
expect { browser.div(id: 'bar').when_present(1).click }.to raise_error(Watir::Wait::TimeoutError, msg)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'responds to Element methods' do
|
30
|
-
decorator = browser.div.when_present
|
3
|
+
compliant_on :relaxed_locate do
|
4
|
+
describe Watir do
|
5
|
+
before do
|
6
|
+
browser.goto WatirSpec.url_for('wait.html')
|
7
|
+
end
|
31
8
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
9
|
+
describe '#default_timeout' do
|
10
|
+
context 'when no timeout is specified' do
|
11
|
+
it 'is used by Wait#until' do
|
12
|
+
expect { Watir::Wait.until { false } }.to wait_and_raise_timeout_exception(timeout: 1)
|
13
|
+
end
|
36
14
|
|
37
|
-
|
38
|
-
|
39
|
-
def present?
|
40
|
-
false
|
41
|
-
end
|
15
|
+
it 'is used by Wait#while' do
|
16
|
+
expect { Watir::Wait.while { true } }.to wait_and_raise_timeout_exception(timeout: 1)
|
42
17
|
end
|
43
|
-
element = browser.a(id: 'show_bar').when_present(1)
|
44
|
-
expect(element).to be_present
|
45
|
-
end
|
46
18
|
|
47
|
-
|
48
|
-
|
49
|
-
|
19
|
+
it 'ensures all checks happen once even if time has expired' do
|
20
|
+
Watir.default_timeout = -1
|
21
|
+
expect { browser.link.click }.to_not raise_exception
|
22
|
+
ensure
|
23
|
+
Watir.default_timeout = 30
|
24
|
+
end
|
50
25
|
end
|
51
26
|
end
|
52
27
|
end
|
53
28
|
|
54
|
-
|
55
|
-
|
56
|
-
browser.
|
57
|
-
expect { browser.div(id: 'bar').click }.to_not raise_exception
|
58
|
-
expect(browser.div(id: 'bar').text).to eq 'changed'
|
59
|
-
end
|
60
|
-
|
61
|
-
it "raises exception if the element doesn't appear" do
|
62
|
-
expect { browser.div(id: 'bar').click }.to raise_unknown_object_exception
|
63
|
-
end
|
64
|
-
|
65
|
-
it "raises exception if the element doesn't become enabled" do
|
66
|
-
expect { browser.button(id: 'btn').click }.to raise_object_disabled_exception
|
29
|
+
describe Watir::Element do
|
30
|
+
before do
|
31
|
+
browser.goto WatirSpec.url_for('wait.html')
|
67
32
|
end
|
68
|
-
end
|
69
|
-
|
70
|
-
not_compliant_on :relaxed_locate do
|
71
|
-
describe '#wait_until &:enabled?' do
|
72
|
-
it 'invokes subsequent method calls when the element becomes enabled' do
|
73
|
-
browser.a(id: 'enable_btn').click
|
74
33
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
expect(
|
34
|
+
describe '#wait_until' do
|
35
|
+
it 'returns element for additional actions' do
|
36
|
+
element = browser.div(id: 'foo')
|
37
|
+
expect(element.wait_until(&:exist?)).to eq element
|
79
38
|
end
|
80
39
|
|
81
|
-
it '
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
element = browser.button(id: 'btn')
|
86
|
-
expect { element.wait_until(timeout: 1, &:enabled?).click }.to raise_error(error, message)
|
40
|
+
it 'accepts self in block' do
|
41
|
+
element = browser.div(id: 'bar')
|
42
|
+
browser.a(id: 'show_bar').click
|
43
|
+
expect { element.wait_until { |el| el.text == 'bar' } }.to_not raise_exception
|
87
44
|
end
|
88
45
|
|
89
|
-
it '
|
90
|
-
element = browser.
|
91
|
-
|
92
|
-
expect(element).to respond_to(:exist?)
|
93
|
-
expect(element).to respond_to(:present?)
|
94
|
-
expect(element).to respond_to(:click)
|
46
|
+
it 'accepts any values in block' do
|
47
|
+
element = browser.div(id: 'bar')
|
48
|
+
expect { element.wait_until { true } }.to_not raise_exception
|
95
49
|
end
|
96
50
|
|
97
|
-
it '
|
98
|
-
browser.
|
99
|
-
|
100
|
-
|
101
|
-
expect(browser.button(id: 'btn2')).to exist
|
102
|
-
expect(browser.button(id: 'btn2')).to be_enabled
|
51
|
+
it 'accepts just a timeout parameter' do
|
52
|
+
element = browser.div(id: 'bar')
|
53
|
+
expect { element.wait_until(timeout: 0) { true } }.to_not raise_exception
|
103
54
|
end
|
104
|
-
end
|
105
|
-
end
|
106
55
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
expect { browser.div(id: 'bar').wait_until_present(timeout: 5) }.to_not raise_exception
|
112
|
-
}.to have_deprecated_wait_until_present
|
113
|
-
end
|
56
|
+
it 'accepts just a message parameter' do
|
57
|
+
element = browser.div(id: 'bar')
|
58
|
+
expect { element.wait_until(message: 'no') { true } }.to_not raise_exception
|
59
|
+
end
|
114
60
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
}.to have_deprecated_wait_until_present
|
120
|
-
end
|
61
|
+
it 'accepts just an interval parameter' do
|
62
|
+
element = browser.div(id: 'bar')
|
63
|
+
expect { element.wait_until(interval: 0.1) { true } }.to_not raise_exception
|
64
|
+
end
|
121
65
|
|
122
|
-
|
123
|
-
|
124
|
-
error = Watir::Wait::TimeoutError
|
125
|
-
message = "timed out after 1 seconds, waiting for #{inspected} to become present"
|
66
|
+
context 'accepts keywords instead of block' do
|
67
|
+
before { browser.refresh }
|
126
68
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
69
|
+
it 'accepts text keyword' do
|
70
|
+
element = browser.div(id: 'bar')
|
71
|
+
browser.a(id: 'show_bar').click
|
72
|
+
expect { element.wait_until(text: 'bar') }.to_not raise_exception
|
73
|
+
end
|
131
74
|
|
132
|
-
|
133
|
-
|
134
|
-
|
75
|
+
it 'accepts regular expression value' do
|
76
|
+
element = browser.div(id: 'bar')
|
77
|
+
browser.a(id: 'show_bar').click
|
78
|
+
expect { element.wait_until(style: /block/) }.to_not raise_exception
|
79
|
+
end
|
135
80
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
81
|
+
it 'accepts multiple keywords' do
|
82
|
+
element = browser.div(id: 'bar')
|
83
|
+
browser.a(id: 'show_bar').click
|
84
|
+
expect { element.wait_until(text: 'bar', style: /block/) }.to_not raise_exception
|
85
|
+
end
|
141
86
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
}.to have_deprecated_wait_while_present
|
148
|
-
end
|
87
|
+
it 'accepts custom keyword' do
|
88
|
+
element = browser.div(id: 'bar')
|
89
|
+
browser.a(id: 'show_bar').click
|
90
|
+
expect { element.wait_until(custom: 'bar') }.to_not raise_exception
|
91
|
+
end
|
149
92
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
expect {
|
155
|
-
expect { browser.div(id: 'foo').wait_while_present(timeout: 1) }.to raise_error(error, message)
|
156
|
-
}.to have_deprecated_wait_while_present
|
157
|
-
end
|
93
|
+
it 'times out when single keyword not met' do
|
94
|
+
element = browser.div(id: 'bar')
|
95
|
+
expect { element.wait_until(id: 'foo') }.to raise_timeout_exception
|
96
|
+
end
|
158
97
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
98
|
+
it 'times out when one of multiple keywords not met' do
|
99
|
+
element = browser.div(id: 'bar')
|
100
|
+
expect { element.wait_until(id: 'bar', text: 'foo') }.to raise_timeout_exception
|
101
|
+
end
|
163
102
|
|
164
|
-
|
165
|
-
|
166
|
-
|
103
|
+
it 'times out when a custom keywords not met' do
|
104
|
+
element = browser.div(id: 'bar')
|
105
|
+
expect { element.wait_until(custom: 'foo') }.to raise_timeout_exception
|
106
|
+
end
|
107
|
+
end
|
167
108
|
end
|
168
109
|
|
169
|
-
|
170
|
-
element
|
171
|
-
|
172
|
-
|
110
|
+
describe '#wait_while' do
|
111
|
+
it 'returns element for additional actions' do
|
112
|
+
element = browser.div(id: 'foo')
|
113
|
+
browser.a(id: 'hide_foo').click
|
114
|
+
expect(element.wait_while(&:present?)).to eq element
|
115
|
+
end
|
173
116
|
|
174
|
-
|
175
|
-
|
176
|
-
expect { element.
|
177
|
-
|
178
|
-
end
|
117
|
+
it 'accepts any values in block' do
|
118
|
+
element = browser.div(id: 'foo')
|
119
|
+
expect { element.wait_while { false } }.to_not raise_exception
|
120
|
+
end
|
179
121
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
expect { element.wait_while_present }.not_to raise_error
|
185
|
-
}.to have_deprecated_wait_while_present
|
186
|
-
end
|
187
|
-
end
|
122
|
+
it 'accepts just a timeout parameter' do
|
123
|
+
element = browser.div(id: 'foo')
|
124
|
+
expect { element.wait_while(timeout: 0) { false } }.to_not raise_exception
|
125
|
+
end
|
188
126
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
end
|
127
|
+
it 'accepts just a message parameter' do
|
128
|
+
element = browser.div(id: 'foo')
|
129
|
+
expect { element.wait_while(message: 'no') { false } }.to_not raise_exception
|
130
|
+
end
|
194
131
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
end
|
132
|
+
it 'accepts just an interval parameter' do
|
133
|
+
element = browser.div(id: 'foo')
|
134
|
+
expect { element.wait_while(interval: 0.1) { false } }.to_not raise_exception
|
135
|
+
end
|
200
136
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
137
|
+
context 'accepts keywords instead of block' do
|
138
|
+
bug 'Safari does not recognize date type', :safari do
|
139
|
+
it 'accepts text keyword' do
|
140
|
+
element = browser.div(id: 'foo')
|
141
|
+
browser.a(id: 'hide_foo').click
|
142
|
+
expect { element.wait_while(text: 'foo') }.to_not raise_exception
|
143
|
+
end
|
144
|
+
end
|
205
145
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
146
|
+
it 'accepts regular expression value' do
|
147
|
+
element = browser.div(id: 'foo')
|
148
|
+
browser.a(id: 'hide_foo').click
|
149
|
+
expect { element.wait_while(style: /block/) }.to_not raise_exception
|
150
|
+
end
|
210
151
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
152
|
+
it 'accepts multiple keywords' do
|
153
|
+
element = browser.div(id: 'foo')
|
154
|
+
browser.a(id: 'hide_foo').click
|
155
|
+
expect { element.wait_while(text: 'foo', style: /block/) }.to_not raise_exception
|
156
|
+
end
|
215
157
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
158
|
+
it 'accepts custom attributes' do
|
159
|
+
element = browser.div(id: 'foo')
|
160
|
+
browser.a(id: 'hide_foo').click
|
161
|
+
expect { element.wait_while(custom: '') }.to_not raise_exception
|
162
|
+
end
|
220
163
|
|
221
|
-
|
222
|
-
|
164
|
+
it 'accepts keywords and block' do
|
165
|
+
element = browser.div(id: 'foo')
|
166
|
+
browser.a(id: 'hide_foo').click
|
167
|
+
expect { element.wait_while(custom: '', &:present?) }.to_not raise_exception
|
168
|
+
end
|
223
169
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
end
|
170
|
+
it 'browser accepts keywords' do
|
171
|
+
expect { browser.wait_until(title: 'wait test') }.to_not raise_exception
|
172
|
+
expect { browser.wait_until(title: 'wrong') }.to raise_timeout_exception
|
173
|
+
end
|
229
174
|
|
230
|
-
|
231
|
-
|
232
|
-
browser.a(id: 'show_bar').click
|
233
|
-
expect { element.wait_until(style: /block/) }.to_not raise_exception
|
234
|
-
end
|
175
|
+
it 'alert accepts keywords' do
|
176
|
+
browser.goto WatirSpec.url_for('alerts.html')
|
235
177
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
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
|
184
|
+
end
|
185
|
+
end
|
241
186
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
end
|
187
|
+
it 'window accepts keywords' do
|
188
|
+
expect { browser.window.wait_until(title: 'wait test') }.to_not raise_exception
|
189
|
+
expect { browser.window.wait_until(title: 'wrong') }.to raise_timeout_exception
|
190
|
+
end
|
247
191
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
192
|
+
it 'times out when single keyword not met' do
|
193
|
+
element = browser.div(id: 'foo')
|
194
|
+
expect { element.wait_while(id: 'foo') }.to raise_timeout_exception
|
195
|
+
end
|
252
196
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
197
|
+
it 'times out when one of multiple keywords not met' do
|
198
|
+
element = browser.div(id: 'foo')
|
199
|
+
browser.a(id: 'hide_foo').click
|
200
|
+
expect { element.wait_while(id: 'foo', style: /block/) }.to raise_timeout_exception
|
201
|
+
end
|
257
202
|
|
258
|
-
|
259
|
-
|
260
|
-
|
203
|
+
it 'times out when one of custom keywords not met' do
|
204
|
+
element = browser.div(id: 'foo')
|
205
|
+
expect { element.wait_while(custom: '') }.to raise_timeout_exception
|
206
|
+
end
|
261
207
|
end
|
262
208
|
end
|
263
|
-
end
|
264
|
-
|
265
|
-
describe '#wait_while' do
|
266
|
-
it 'returns element for additional actions' do
|
267
|
-
element = browser.div(id: 'foo')
|
268
|
-
browser.a(id: 'hide_foo').click
|
269
|
-
expect(element.wait_while(&:present?)).to eq element
|
270
|
-
end
|
271
209
|
|
272
|
-
|
273
|
-
it '
|
274
|
-
element = browser.
|
275
|
-
|
276
|
-
expect { element.wait_while { |el| el.text == 'foo' } }.to_not raise_exception
|
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
|
277
214
|
end
|
278
215
|
end
|
279
216
|
|
280
|
-
|
281
|
-
|
282
|
-
|
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
|
283
221
|
end
|
284
222
|
|
285
|
-
|
286
|
-
element
|
287
|
-
|
288
|
-
|
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
|
289
231
|
|
290
|
-
|
291
|
-
|
292
|
-
|
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
|
293
238
|
end
|
294
239
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
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
|
299
244
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
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)
|
305
250
|
end
|
251
|
+
end
|
306
252
|
|
307
|
-
|
308
|
-
|
309
|
-
browser.
|
310
|
-
expect { element.wait_while(style: /block/) }.to_not raise_exception
|
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
|
311
256
|
end
|
312
257
|
|
313
|
-
it '
|
314
|
-
|
315
|
-
|
316
|
-
|
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)
|
317
263
|
end
|
264
|
+
end
|
318
265
|
|
319
|
-
|
320
|
-
|
321
|
-
browser.
|
322
|
-
expect { element.
|
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
|
323
270
|
end
|
324
271
|
|
325
|
-
it '
|
326
|
-
element = browser.
|
327
|
-
|
328
|
-
expect { element.wait_while(custom: '', &:present?) }.to_not raise_exception
|
272
|
+
it 'raises exception after timing out when element from a collection whose parent is never present' do
|
273
|
+
element = browser.link(id: 'not_there')
|
274
|
+
expect { element.elements[2].click }.to wait_and_raise_unknown_object_exception
|
329
275
|
end
|
330
276
|
|
331
|
-
it '
|
332
|
-
|
333
|
-
expect {
|
277
|
+
it 'does not wait for parent element to be present when querying child element' do
|
278
|
+
el = browser.element(id: 'not_there').element(id: 'doesnt_matter')
|
279
|
+
expect { el.present? }.to execute_when_satisfied(max: 1)
|
334
280
|
end
|
281
|
+
end
|
282
|
+
end
|
335
283
|
|
336
|
-
|
337
|
-
|
284
|
+
describe Watir::ElementCollection do
|
285
|
+
before do
|
286
|
+
browser.goto WatirSpec.url_for('wait.html')
|
287
|
+
end
|
338
288
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
ensure
|
344
|
-
browser.alert.ok
|
345
|
-
end
|
289
|
+
describe '#wait_until' do
|
290
|
+
it 'returns collection' do
|
291
|
+
elements = browser.divs
|
292
|
+
expect(elements.wait_until(&:exist?)).to eq elements
|
346
293
|
end
|
347
294
|
|
348
|
-
it '
|
349
|
-
expect { browser.
|
350
|
-
expect { browser.window.wait_until(title: 'wrong') }.to raise_timeout_exception
|
295
|
+
it 'times out when waiting for non-empty collection' do
|
296
|
+
expect { browser.divs.wait_until(&:empty?) }.to raise_timeout_exception
|
351
297
|
end
|
352
298
|
|
353
|
-
it '
|
354
|
-
|
355
|
-
|
299
|
+
it 'provides matching collection when exists' do
|
300
|
+
expect {
|
301
|
+
browser.a(id: 'add_foobar').click
|
302
|
+
browser.divs(id: 'foobar').wait_until(&:exists?)
|
303
|
+
}.to execute_when_satisfied(min: 1)
|
356
304
|
end
|
357
305
|
|
358
|
-
it '
|
359
|
-
|
360
|
-
|
361
|
-
|
306
|
+
it 'accepts self in block' do
|
307
|
+
expect {
|
308
|
+
browser.a(id: 'add_foobar').click
|
309
|
+
browser.divs.wait_until { |els| els.size == 7 }
|
310
|
+
}.to execute_when_satisfied(min: 1)
|
362
311
|
end
|
363
312
|
|
364
|
-
it '
|
365
|
-
|
366
|
-
|
313
|
+
it 'accepts attributes to evaluate' do
|
314
|
+
expect {
|
315
|
+
browser.a(id: 'add_foobar').click
|
316
|
+
browser.divs.wait_until(size: 7)
|
317
|
+
}.to execute_when_satisfied(min: 1)
|
367
318
|
end
|
368
319
|
end
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
describe Watir do
|
373
|
-
describe '#default_timeout' do
|
374
|
-
before do
|
375
|
-
browser.goto WatirSpec.url_for('wait.html')
|
376
|
-
end
|
377
320
|
|
378
|
-
|
379
|
-
it '
|
380
|
-
|
321
|
+
describe '#wait_while' do
|
322
|
+
it 'returns collection' do
|
323
|
+
elements = browser.divs
|
324
|
+
expect(elements.wait_while(&:empty?)).to eq elements
|
381
325
|
end
|
382
326
|
|
383
|
-
it '
|
384
|
-
|
327
|
+
it 'times out when waiting for non-empty collection' do
|
328
|
+
elements = browser.divs
|
329
|
+
expect { elements.wait_while(&:exists?) }.to raise_timeout_exception
|
385
330
|
end
|
386
331
|
|
387
|
-
it '
|
332
|
+
it 'provides matching collection when exists' do
|
388
333
|
expect {
|
389
|
-
|
390
|
-
|
334
|
+
browser.a(id: 'remove_foo').click
|
335
|
+
browser.divs(id: 'foo').wait_while(&:exists?)
|
336
|
+
}.to execute_when_satisfied(min: 1)
|
391
337
|
end
|
392
338
|
|
393
|
-
it '
|
339
|
+
it 'accepts self in block' do
|
394
340
|
expect {
|
395
|
-
|
396
|
-
|
341
|
+
browser.a(id: 'add_foobar').click
|
342
|
+
browser.divs.wait_while { |els| els.size == 6 }
|
343
|
+
}.to execute_when_satisfied(min: 1)
|
397
344
|
end
|
398
345
|
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
|
399
351
|
end
|
400
352
|
end
|