watir 6.16.2 → 6.18.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 +31 -0
- data/.github/workflows/windows.yml +39 -0
- data/.rubocop.yml +32 -107
- data/.rubocop_todo.yml +36 -0
- data/CHANGES.md +42 -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 +1 -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 +9 -6
- 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/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 +22 -12
- 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/matcher.rb +1 -1
- 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 +105 -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 +5 -1
- data/lib/watirspec/server.rb +1 -1
- data/spec/spec_helper.rb +2 -7
- 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 +17 -13
- data/spec/watirspec/user_editable_spec.rb +1 -1
- data/spec/watirspec/wait_spec.rb +257 -305
- data/spec/watirspec/window_switching_spec.rb +332 -211
- data/spec/watirspec_helper.rb +16 -19
- data/support/doctest_helper.rb +0 -2
- data/watir.gemspec +6 -7
- metadata +36 -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
@@ -1,47 +1,23 @@
|
|
1
1
|
require 'watirspec_helper'
|
2
2
|
|
3
3
|
describe 'Element' do
|
4
|
-
|
5
|
-
|
6
|
-
context 'drag and drop' do
|
7
|
-
before { browser.goto WatirSpec.url_for('drag_and_drop.html') }
|
4
|
+
context 'drag and drop' do
|
5
|
+
before { browser.goto WatirSpec.url_for('drag_and_drop.html') }
|
8
6
|
|
9
|
-
|
10
|
-
|
7
|
+
let(:draggable) { browser.div id: 'draggable' }
|
8
|
+
let(:droppable) { browser.div id: 'droppable' }
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
not_compliant_on :headless, :firefox do
|
19
|
-
it 'can drag and drop an element onto another when draggable is out of viewport' do
|
20
|
-
reposition 'draggable'
|
21
|
-
perform_drag_and_drop_on_droppable
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'can drag and drop an element onto another when droppable is out of viewport' do
|
25
|
-
reposition 'droppable'
|
26
|
-
perform_drag_and_drop_on_droppable
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'can drag an element by the given offset' do
|
31
|
-
expect(droppable.text).to eq 'Drop here'
|
32
|
-
draggable.drag_and_drop_by 200, 50
|
33
|
-
expect(droppable.text).to eq 'Dropped!'
|
34
|
-
end
|
35
|
-
|
36
|
-
def reposition(what)
|
37
|
-
browser.button(id: "reposition#{what.capitalize}").click
|
38
|
-
end
|
10
|
+
it 'can drag and drop an element onto another' do
|
11
|
+
expect(droppable.text).to include 'Drop here'
|
12
|
+
draggable.drag_and_drop_on droppable
|
13
|
+
expect(droppable.text).to include 'Dropped!'
|
14
|
+
end
|
39
15
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
16
|
+
bug 'Element is getting moved to the wrong spot', :w3c do
|
17
|
+
it 'can drag an element by the given offset' do
|
18
|
+
expect(droppable.text).to include 'Drop here'
|
19
|
+
draggable.drag_and_drop_by 200, 50
|
20
|
+
expect(droppable.text).to include 'Dropped!'
|
45
21
|
end
|
46
22
|
end
|
47
23
|
end
|
@@ -37,6 +37,8 @@ describe 'Button' do
|
|
37
37
|
expect(browser.button(text: /Button 2/)).to exist
|
38
38
|
expect(browser.button(value: 'Button 2')).to exist
|
39
39
|
expect(browser.button(value: /Button 2/)).to exist
|
40
|
+
expect(browser.button(value: 'Button 4 With Child Text')).to exist
|
41
|
+
expect(browser.button(value: /Button 4 With Child Text/)).to exist
|
40
42
|
end
|
41
43
|
|
42
44
|
it 'returns true if the button exists (how = :caption)' do
|
@@ -39,12 +39,16 @@ describe 'CheckBox' do
|
|
39
39
|
expect {
|
40
40
|
expect(browser.checkbox(label: /this will not match/)).to exist
|
41
41
|
}.to_not have_deprecated_text_regexp
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
+
bug 'Safari is not filtering out hidden text', :safari do
|
45
|
+
it 'handles text_regexp deprecation in spite of hidden text' do
|
46
|
+
expect(browser.checkbox(label: /some visible some hidden/)).to_not exist
|
44
47
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
+
expect {
|
49
|
+
expect(browser.checkbox(label: /some visible$/)).to exist
|
50
|
+
}.to have_deprecated_text_regexp
|
51
|
+
end
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
@@ -15,17 +15,24 @@ describe 'DateField' do
|
|
15
15
|
expect(browser.date_field(text: '')).to exist
|
16
16
|
expect(browser.date_field(text: //)).to exist
|
17
17
|
expect(browser.date_field(index: 0)).to exist
|
18
|
-
expect(browser.date_field(xpath: "//input[@id='html5_date']")).to exist
|
19
18
|
expect(browser.date_field(label: 'HTML5 Date')).to exist
|
20
19
|
expect(browser.date_field(label: /Date$/)).to exist
|
21
20
|
end
|
22
21
|
|
22
|
+
bug 'Safari does not recognize date type', :safari do
|
23
|
+
it 'returns true when using xpath' do
|
24
|
+
expect(browser.date_field(xpath: "//input[@id='html5_date']")).to exist
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
23
28
|
it 'returns the date field if given no args' do
|
24
29
|
expect(browser.date_field).to exist
|
25
30
|
end
|
26
31
|
|
27
|
-
|
28
|
-
|
32
|
+
bug 'Safari does not recognize date type', :safari do
|
33
|
+
it 'respects date fields types' do
|
34
|
+
expect(browser.date_field.type).to eq('date')
|
35
|
+
end
|
29
36
|
end
|
30
37
|
|
31
38
|
it 'returns false if the element does not exist' do
|
@@ -71,13 +78,15 @@ describe 'DateField' do
|
|
71
78
|
end
|
72
79
|
end
|
73
80
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
81
|
+
bug 'Safari does not recognize date type', :safari do
|
82
|
+
describe '#type' do
|
83
|
+
it 'returns the type attribute if the date field exists' do
|
84
|
+
expect(browser.date_field(id: 'html5_date').type).to eq 'date'
|
85
|
+
end
|
78
86
|
|
79
|
-
|
80
|
-
|
87
|
+
it "raises UnknownObjectException if the date field doesn't exist" do
|
88
|
+
expect { browser.date_field(index: 1337).type }.to raise_unknown_object_exception
|
89
|
+
end
|
81
90
|
end
|
82
91
|
end
|
83
92
|
|
@@ -16,8 +16,7 @@ describe 'DateTimeField' do
|
|
16
16
|
expect(browser.date_time_field(text: //)).to exist
|
17
17
|
expect(browser.date_time_field(index: 0)).to exist
|
18
18
|
|
19
|
-
|
20
|
-
not_compliant_on :firefox do
|
19
|
+
bug 'https://github.com/mozilla/geckodriver/issues/1469', :firefox, :safari do
|
21
20
|
expect(browser.date_time_field(xpath: "//input[@id='html5_datetime-local']")).to exist
|
22
21
|
end
|
23
22
|
|
@@ -29,7 +28,7 @@ describe 'DateTimeField' do
|
|
29
28
|
expect(browser.date_time_field).to exist
|
30
29
|
end
|
31
30
|
|
32
|
-
bug 'https://
|
31
|
+
bug 'https://github.com/mozilla/geckodriver/issues/1469', :firefox, :safari do
|
33
32
|
it 'respects date-time fields types' do
|
34
33
|
expect(browser.date_time_field.type).to eq('datetime-local')
|
35
34
|
end
|
@@ -79,7 +78,7 @@ describe 'DateTimeField' do
|
|
79
78
|
end
|
80
79
|
|
81
80
|
describe '#type' do
|
82
|
-
bug 'https://
|
81
|
+
bug 'https://github.com/mozilla/geckodriver/issues/1469', :firefox, :safari do
|
83
82
|
it 'returns the type attribute if the date-time field exists' do
|
84
83
|
expect(browser.date_time_field(id: 'html5_datetime-local').type).to eq 'datetime-local'
|
85
84
|
end
|
@@ -97,7 +97,7 @@ describe 'Div' do
|
|
97
97
|
expect(browser.div(index: 0).text.strip).to eq ''
|
98
98
|
end
|
99
99
|
|
100
|
-
|
100
|
+
bug 'Safari is not filtering out hidden text', :safari do
|
101
101
|
it 'returns an empty string if the div is hidden' do
|
102
102
|
expect(browser.div(id: 'hidden').text).to eq ''
|
103
103
|
end
|
@@ -137,8 +137,10 @@ describe 'Div' do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
not_compliant_on :watigiri do
|
140
|
-
|
141
|
-
|
140
|
+
bug 'Safari is not filtering out hidden text', :safari do
|
141
|
+
it 'throws deprecation when no longer matched by text content' do
|
142
|
+
expect { browser.div(text: /some visible$/).locate }.to have_deprecated_text_regexp
|
143
|
+
end
|
142
144
|
end
|
143
145
|
end
|
144
146
|
|
@@ -148,77 +150,83 @@ describe 'Div' do
|
|
148
150
|
end
|
149
151
|
end
|
150
152
|
|
151
|
-
# Note: This will work after:text_regexp deprecation removed
|
152
153
|
not_compliant_on :watigiri do
|
153
|
-
|
154
|
-
|
154
|
+
bug 'Safari is not filtering out hidden text', :safari do
|
155
|
+
it 'does not locate entire content with regular expressions' do
|
156
|
+
expect(browser.div(text: /some visible some hidden/)).to_not exist
|
157
|
+
end
|
155
158
|
end
|
156
159
|
end
|
157
160
|
end
|
158
161
|
end
|
159
162
|
|
160
163
|
# Manipulation methods
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
expect(browser.div(id: 'best_language').text).to_not eq 'Ruby!'
|
165
|
-
browser.div(id: 'best_language').click
|
166
|
-
expect(browser.div(id: 'best_language').text).to eq 'Ruby!'
|
167
|
-
end
|
164
|
+
describe '#click' do
|
165
|
+
it 'fires events when clicked' do
|
166
|
+
expect(browser.div(id: 'best_language').text).to_not eq 'Ruby!'
|
168
167
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
end
|
168
|
+
div = browser.div(id: 'best_language')
|
169
|
+
div.scroll.to
|
170
|
+
div.click
|
171
|
+
expect(browser.div(id: 'best_language').text).to eq 'Ruby!'
|
172
|
+
end
|
175
173
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
174
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
175
|
+
expect { browser.div(id: 'no_such_id').click }.to raise_unknown_object_exception
|
176
|
+
expect { browser.div(title: 'no_such_title').click }.to raise_unknown_object_exception
|
177
|
+
expect { browser.div(index: 1337).click }.to raise_unknown_object_exception
|
178
|
+
expect { browser.div(xpath: "//div[@id='no_such_id']").click }.to raise_unknown_object_exception
|
180
179
|
end
|
181
180
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
end
|
181
|
+
it 'includes custom message if element with a custom attribute does not exist' do
|
182
|
+
message = /Watir treated \["custom_attribute"\] as a non-HTML compliant attribute, ensure that was intended/
|
183
|
+
expect { browser.div(custom_attribute: 'not_there').click }.to raise_unknown_object_exception(message)
|
184
|
+
end
|
185
|
+
end
|
188
186
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
187
|
+
describe '#click!' do
|
188
|
+
it 'fires events when clicked' do
|
189
|
+
expect(browser.div(id: 'best_language').text).to_not eq 'Ruby!'
|
190
|
+
browser.div(id: 'best_language').click!
|
191
|
+
expect(browser.div(id: 'best_language').text).to eq 'Ruby!'
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
195
|
+
expect { browser.div(id: 'no_such_id').click! }.to raise_unknown_object_exception
|
196
|
+
expect { browser.div(title: 'no_such_title').click! }.to raise_unknown_object_exception
|
197
|
+
expect { browser.div(index: 1337).click! }.to raise_unknown_object_exception
|
198
|
+
expect { browser.div(xpath: "//div[@id='no_such_id']").click! }.to raise_unknown_object_exception
|
195
199
|
end
|
196
200
|
end
|
197
201
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
202
|
+
bug 'command correctly received, but action not taken', :safari, :w3c do
|
203
|
+
describe '#double_click' do
|
204
|
+
it 'fires the ondblclick event' do
|
205
|
+
div = browser.div(id: 'html_test')
|
206
|
+
div.scroll.to
|
207
|
+
div.double_click
|
208
|
+
expect(messages).to include('double clicked')
|
205
209
|
end
|
210
|
+
end
|
206
211
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
end
|
212
|
+
describe '#double_click!' do
|
213
|
+
it 'fires the ondblclick event' do
|
214
|
+
browser.div(id: 'html_test').double_click!
|
215
|
+
expect(messages).to include('double clicked')
|
212
216
|
end
|
213
217
|
end
|
214
218
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
219
|
+
describe '#right_click' do
|
220
|
+
it 'fires the oncontextmenu event' do
|
221
|
+
browser.goto(WatirSpec.url_for('right_click.html'))
|
222
|
+
browser.div(id: 'click').right_click
|
223
|
+
expect(messages.first).to eq 'right-clicked'
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'accepts modifiers' do
|
227
|
+
browser.goto(WatirSpec.url_for('right_click.html'))
|
228
|
+
browser.div(id: 'click-logger').right_click(:control, :alt)
|
229
|
+
expect(event_log.first).to eq('control=true alt=true')
|
222
230
|
end
|
223
231
|
end
|
224
232
|
end
|
@@ -104,24 +104,30 @@ describe 'Element' do
|
|
104
104
|
|
105
105
|
expect(browser.element(visible_text: 'all visible')).to exist
|
106
106
|
expect(browser.element(visible_text: /all visible/)).to exist
|
107
|
-
expect(browser.element(visible_text: 'some visible')).to exist
|
108
107
|
expect(browser.element(visible_text: /some visible/)).to exist
|
109
|
-
expect(browser.element(visible_text: 'none visible')).not_to exist
|
110
|
-
expect(browser.element(visible_text: /none visible/)).not_to exist
|
111
|
-
|
112
108
|
expect(browser.element(visible_text: 'Link 2', class: 'external')).to exist
|
113
109
|
expect(browser.element(visible_text: /Link 2/, class: 'external')).to exist
|
114
110
|
end
|
115
111
|
|
112
|
+
bug 'Safari is not filtering out hidden text', :safari do
|
113
|
+
it 'finds elements by visible text in spite of hidden text' do
|
114
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
115
|
+
|
116
|
+
expect(browser.element(visible_text: 'some visible')).to exist
|
117
|
+
expect(browser.element(visible_text: 'none visible')).not_to exist
|
118
|
+
expect(browser.element(visible_text: /none visible/)).not_to exist
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
116
122
|
it 'raises exception unless value is a String or a RegExp' do
|
117
123
|
browser.goto WatirSpec.url_for('non_control_elements.html')
|
118
|
-
msg = /expected one of \[String, Regexp\], got 7
|
124
|
+
msg = /expected one of \[String, Regexp\], got 7:Integer/
|
119
125
|
expect { browser.element(visible_text: 7).exists? }.to raise_exception(TypeError, msg)
|
120
126
|
end
|
121
127
|
|
122
128
|
it 'raises exception unless key is valid' do
|
123
129
|
browser.goto WatirSpec.url_for('non_control_elements.html')
|
124
|
-
msg = /Unable to build XPath using 7:
|
130
|
+
msg = /Unable to build XPath using 7:Integer/
|
125
131
|
expect { browser.element(7 => /foo/).exists? }.to raise_exception(Watir::Exception::Error, msg)
|
126
132
|
end
|
127
133
|
end
|
@@ -225,32 +231,29 @@ describe 'Element' do
|
|
225
231
|
|
226
232
|
describe '#visible?' do
|
227
233
|
it 'returns true if the element is visible' do
|
228
|
-
msg = /WARN Watir \[
|
234
|
+
msg = /WARN Watir \["visible_element"\]/
|
229
235
|
expect {
|
230
236
|
expect(browser.text_field(id: 'new_user_email')).to be_visible
|
231
237
|
}.to output(msg).to_stdout_from_any_process
|
232
238
|
end
|
233
239
|
|
234
240
|
it 'raises UnknownObjectException exception if the element does not exist' do
|
235
|
-
msg = /WARN Watir \[
|
241
|
+
msg = /WARN Watir \["visible_element"\]/
|
236
242
|
expect {
|
237
243
|
expect { browser.text_field(id: 'no_such_id').visible? }.to raise_unknown_object_exception
|
238
244
|
}.to output(msg).to_stdout_from_any_process
|
239
245
|
end
|
240
246
|
|
241
|
-
it '
|
247
|
+
it 'handles staleness' do
|
242
248
|
element = browser.text_field(id: 'new_user_email').locate
|
243
249
|
|
244
|
-
|
250
|
+
allow(element).to receive(:stale?).and_return(true)
|
245
251
|
|
246
|
-
expect(element).to
|
247
|
-
expect {
|
248
|
-
expect { element.visible? }.to raise_unknown_object_exception
|
249
|
-
}.to have_deprecated_stale_visible
|
252
|
+
expect(element).to be_visible
|
250
253
|
end
|
251
254
|
|
252
255
|
it "returns true if the element has style='visibility: visible' even if parent has style='visibility: hidden'" do
|
253
|
-
msg = /WARN Watir \[
|
256
|
+
msg = /WARN Watir \["visible_element"\]/
|
254
257
|
expect {
|
255
258
|
expect(browser.div(id: 'visible_child')).to be_visible
|
256
259
|
}.to output(msg).to_stdout_from_any_process
|
@@ -261,7 +264,7 @@ describe 'Element' do
|
|
261
264
|
end
|
262
265
|
|
263
266
|
it "returns false if the element has style='display: none;'" do
|
264
|
-
msg = /WARN Watir \[
|
267
|
+
msg = /WARN Watir \["visible_element"\]/
|
265
268
|
expect {
|
266
269
|
expect(browser.div(id: 'changed_language')).to_not be_visible
|
267
270
|
}.to output(msg).to_stdout_from_any_process
|
@@ -295,9 +298,7 @@ describe 'Element' do
|
|
295
298
|
element.cache = wd
|
296
299
|
|
297
300
|
browser.refresh
|
298
|
-
expect
|
299
|
-
expect(element).to_not exist
|
300
|
-
}.to have_deprecated_stale_exists
|
301
|
+
expect(element).to_not exist
|
301
302
|
end
|
302
303
|
end
|
303
304
|
|
@@ -306,15 +307,12 @@ describe 'Element' do
|
|
306
307
|
browser.goto WatirSpec.url_for('removed_element.html')
|
307
308
|
end
|
308
309
|
|
309
|
-
it '
|
310
|
+
it 'handles staleness in a collection' do
|
310
311
|
element = browser.divs(id: 'text').first.locate
|
311
312
|
|
312
|
-
|
313
|
+
allow(element).to receive(:stale?).and_return(true)
|
313
314
|
|
314
|
-
expect(element).to
|
315
|
-
expect {
|
316
|
-
expect(element).to_not exist
|
317
|
-
}.to have_deprecated_stale_exists
|
315
|
+
expect(element).to exist
|
318
316
|
end
|
319
317
|
|
320
318
|
it 'returns false when tag name does not match id' do
|
@@ -340,36 +338,11 @@ describe 'Element' do
|
|
340
338
|
expect(browser.div(id: 'should-not-exist')).to_not be_present
|
341
339
|
end
|
342
340
|
|
343
|
-
it '
|
344
|
-
element = browser.div(id: 'foo').locate
|
345
|
-
|
346
|
-
browser.refresh
|
347
|
-
|
348
|
-
expect(element).to be_stale
|
349
|
-
|
350
|
-
expect {
|
351
|
-
expect(element).to_not be_present
|
352
|
-
}.to have_deprecated_stale_present
|
353
|
-
end
|
354
|
-
|
355
|
-
it 'does not raise staleness deprecation if element no longer exists in DOM' do
|
341
|
+
it 'handles staleness' do
|
356
342
|
element = browser.div(id: 'foo').locate
|
357
|
-
browser.goto(WatirSpec.url_for('iframes.html'))
|
358
343
|
|
359
|
-
|
360
|
-
end
|
361
|
-
|
362
|
-
# TODO: Documents Current Behavior, but needs to be refactored/removed
|
363
|
-
it 'returns true the second time if the element is stale' do
|
364
|
-
element = browser.div(id: 'foo').locate
|
344
|
+
allow(element).to receive(:stale?).and_return(true)
|
365
345
|
|
366
|
-
browser.refresh
|
367
|
-
|
368
|
-
expect(element).to be_stale
|
369
|
-
|
370
|
-
expect {
|
371
|
-
expect(element).to_not be_present
|
372
|
-
}.to have_deprecated_stale_present
|
373
346
|
expect(element).to be_present
|
374
347
|
end
|
375
348
|
end
|
@@ -535,8 +508,8 @@ describe 'Element' do
|
|
535
508
|
expect(events).to eq 10
|
536
509
|
end
|
537
510
|
|
538
|
-
bug 'http://code.google.com/p/chromium/issues/detail?id=93879',
|
539
|
-
|
511
|
+
bug 'http://code.google.com/p/chromium/issues/detail?id=93879', %i[chrome macosx] do
|
512
|
+
bug 'special keys are not working correctly', :safari, :firefox do
|
540
513
|
it 'performs key combinations' do
|
541
514
|
receiver.send_keys 'foo'
|
542
515
|
receiver.send_keys [@c, 'a']
|
@@ -562,14 +535,14 @@ describe 'Element' do
|
|
562
535
|
end
|
563
536
|
|
564
537
|
describe '#click' do
|
565
|
-
bug '
|
566
|
-
|
567
|
-
|
538
|
+
bug 'Element has been located but Safari does not recognize it', :safari do
|
539
|
+
bug 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=2732', :w3c do
|
540
|
+
it 'accepts modifiers' do
|
568
541
|
browser.a.click(:shift)
|
542
|
+
browser.wait_until { |b| b.windows.size > 1 }
|
569
543
|
expect(browser.windows.size).to eq 2
|
570
544
|
ensure
|
571
545
|
browser.windows.reject(&:current?).each(&:close)
|
572
|
-
expect(browser.windows.size).to eq 1
|
573
546
|
end
|
574
547
|
end
|
575
548
|
end
|
@@ -597,12 +570,13 @@ describe 'Element' do
|
|
597
570
|
end
|
598
571
|
|
599
572
|
describe '#hover' do
|
600
|
-
not_compliant_on :internet_explorer
|
573
|
+
not_compliant_on :internet_explorer do
|
601
574
|
it 'should hover over the element' do
|
602
575
|
browser.goto WatirSpec.url_for('hover.html')
|
603
576
|
link = browser.a
|
604
577
|
|
605
578
|
expect(link.style('font-size')).to eq '10px'
|
579
|
+
link.scroll.to
|
606
580
|
link.hover
|
607
581
|
link.wait_until { |l| l.style('font-size') == '20px' }
|
608
582
|
expect(link.style('font-size')).to eq '20px'
|
@@ -703,19 +677,22 @@ describe 'Element' do
|
|
703
677
|
end
|
704
678
|
end
|
705
679
|
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
680
|
+
describe '#scroll_into_view' do
|
681
|
+
it 'scrolls element into view' do
|
682
|
+
initial_size = browser.window.size
|
683
|
+
browser.window.resize_to(initial_size.width, 800)
|
684
|
+
|
685
|
+
el = browser.button(name: 'new_user_image')
|
686
|
+
element_center = el.center['y']
|
711
687
|
|
712
|
-
|
713
|
-
|
688
|
+
bottom_viewport_script = 'return window.pageYOffset + window.innerHeight'
|
689
|
+
expect(browser.execute_script(bottom_viewport_script)).to be < element_center
|
714
690
|
|
691
|
+
expect {
|
715
692
|
expect(el.scroll_into_view).to be_a Selenium::WebDriver::Point
|
693
|
+
}.to have_deprecated_scroll_into_view
|
716
694
|
|
717
|
-
|
718
|
-
end
|
695
|
+
expect(browser.execute_script(bottom_viewport_script)).to be > element_center
|
719
696
|
end
|
720
697
|
end
|
721
698
|
|
@@ -732,10 +709,13 @@ describe 'Element' do
|
|
732
709
|
describe '#size' do
|
733
710
|
it 'returns size of element' do
|
734
711
|
size = browser.button(name: 'new_user_image').size
|
735
|
-
|
736
712
|
expect(size).to be_a Selenium::WebDriver::Dimension
|
737
|
-
|
738
|
-
|
713
|
+
|
714
|
+
expected_width = browser.name == :safari ? 105 : 104
|
715
|
+
expected_height = browser.name == :safari ? 71 : 70
|
716
|
+
|
717
|
+
expect(size['width']).to eq expected_width
|
718
|
+
expect(size['height']).to eq expected_height
|
739
719
|
end
|
740
720
|
end
|
741
721
|
|
@@ -743,7 +723,8 @@ describe 'Element' do
|
|
743
723
|
it 'returns height of element' do
|
744
724
|
height = browser.button(name: 'new_user_image').height
|
745
725
|
|
746
|
-
|
726
|
+
expected_height = browser.name == :safari ? 71 : 70
|
727
|
+
expect(height).to eq expected_height
|
747
728
|
end
|
748
729
|
end
|
749
730
|
|
@@ -751,7 +732,8 @@ describe 'Element' do
|
|
751
732
|
it 'returns width of element' do
|
752
733
|
width = browser.button(name: 'new_user_image').width
|
753
734
|
|
754
|
-
|
735
|
+
expected_width = browser.name == :safari ? 105 : 104
|
736
|
+
expect(width).to eq expected_width
|
755
737
|
end
|
756
738
|
end
|
757
739
|
|
@@ -902,35 +884,36 @@ describe 'Element' do
|
|
902
884
|
describe '#obscured?' do
|
903
885
|
before { browser.goto WatirSpec.url_for('obscured.html') }
|
904
886
|
|
905
|
-
it 'returns false if element
|
887
|
+
it 'returns false if element center is not covered' do
|
906
888
|
btn = browser.button(id: 'not_obscured')
|
907
889
|
expect(btn).not_to be_obscured
|
908
890
|
expect { btn.click }.not_to raise_exception
|
909
891
|
end
|
910
892
|
|
911
|
-
it 'returns false if element
|
893
|
+
it 'returns false if element center is covered by its descendant' do
|
912
894
|
btn = browser.button(id: 'has_descendant')
|
913
895
|
expect(btn).not_to be_obscured
|
914
896
|
expect { btn.click }.not_to raise_exception
|
915
897
|
end
|
916
898
|
|
917
|
-
it 'returns true if element
|
899
|
+
it 'returns true if element center is covered by a non-descendant' do
|
918
900
|
btn = browser.button(id: 'obscured')
|
919
901
|
expect(btn).to be_obscured
|
920
|
-
not_compliant_on :chrome do
|
902
|
+
not_compliant_on :chrome, :safari do
|
921
903
|
expect { btn.click }.to raise_exception(Selenium::WebDriver::Error::ElementClickInterceptedError)
|
922
904
|
end
|
923
905
|
compliant_on :chrome do
|
924
|
-
expect { btn.click }.to raise_exception(Selenium::WebDriver::Error::
|
906
|
+
expect { btn.click }.to raise_exception(Selenium::WebDriver::Error::ElementClickInterceptedError)
|
907
|
+
end
|
908
|
+
compliant_on :safari do
|
909
|
+
expect { btn.click }.to raise_exception(Selenium::WebDriver::Error::WebDriverError)
|
925
910
|
end
|
926
911
|
end
|
927
912
|
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
expect { btn.click }.not_to raise_exception
|
933
|
-
end
|
913
|
+
it 'returns false if element center is surrounded by non-descendants' do
|
914
|
+
btn = browser.button(id: 'surrounded')
|
915
|
+
expect(btn).not_to be_obscured
|
916
|
+
expect { btn.click }.not_to raise_exception
|
934
917
|
end
|
935
918
|
|
936
919
|
it 'scrolls interactive element into view before checking if obscured' do
|
@@ -945,10 +928,12 @@ describe 'Element' do
|
|
945
928
|
expect { div.click }.not_to raise_exception
|
946
929
|
end
|
947
930
|
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
931
|
+
bug 'Safari is throwing click intercepted here', :safari do
|
932
|
+
it 'returns true if element cannot be scrolled into view' do
|
933
|
+
btn = browser.button(id: 'off_screen')
|
934
|
+
expect(btn).to be_obscured
|
935
|
+
expect { btn.click }.to raise_unknown_object_exception
|
936
|
+
end
|
952
937
|
end
|
953
938
|
|
954
939
|
it 'returns true if element is hidden' do
|