watir 6.16.5 → 6.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +32 -107
  3. data/.travis.yml +24 -21
  4. data/CHANGES.md +16 -0
  5. data/Gemfile +3 -1
  6. data/Rakefile +3 -3
  7. data/appveyor.yml +2 -1
  8. data/lib/watir-webdriver.rb +1 -1
  9. data/lib/watir.rb +0 -1
  10. data/lib/watir/adjacent.rb +8 -10
  11. data/lib/watir/after_hooks.rb +4 -4
  12. data/lib/watir/browser.rb +5 -1
  13. data/lib/watir/capabilities.rb +9 -6
  14. data/lib/watir/cookies.rb +1 -1
  15. data/lib/watir/elements/element.rb +59 -46
  16. data/lib/watir/elements/file_field.rb +1 -0
  17. data/lib/watir/elements/iframe.rb +2 -2
  18. data/lib/watir/elements/link.rb +0 -9
  19. data/lib/watir/elements/radio.rb +1 -1
  20. data/lib/watir/elements/select.rb +2 -2
  21. data/lib/watir/generator/base/spec_extractor.rb +4 -4
  22. data/lib/watir/js_execution.rb +1 -1
  23. data/lib/watir/legacy_wait.rb +1 -1
  24. data/lib/watir/locators/element/selector_builder.rb +11 -12
  25. data/lib/watir/locators/element/selector_builder/xpath.rb +40 -13
  26. data/lib/watir/locators/text_field/selector_builder/xpath.rb +3 -1
  27. data/lib/watir/logger.rb +5 -2
  28. data/lib/watir/version.rb +1 -1
  29. data/lib/watir/window.rb +1 -1
  30. data/lib/watirspec.rb +1 -1
  31. data/lib/watirspec/guards.rb +1 -1
  32. data/lib/watirspec/rake_tasks.rb +2 -0
  33. data/lib/watirspec/runner.rb +4 -0
  34. data/spec/unit/container_spec.rb +1 -1
  35. data/spec/unit/logger_spec.rb +5 -7
  36. data/spec/unit/selector_builder/button_spec.rb +16 -15
  37. data/spec/unit/selector_builder/element_spec.rb +58 -9
  38. data/spec/unit/selector_builder/text_field_spec.rb +14 -14
  39. data/spec/watirspec/after_hooks_spec.rb +64 -78
  40. data/spec/watirspec/alert_spec.rb +69 -79
  41. data/spec/watirspec/browser_spec.rb +48 -46
  42. data/spec/watirspec/cookies_spec.rb +52 -37
  43. data/spec/watirspec/drag_and_drop_spec.rb +14 -38
  44. data/spec/watirspec/elements/button_spec.rb +2 -0
  45. data/spec/watirspec/elements/buttons_spec.rb +1 -1
  46. data/spec/watirspec/elements/checkbox_spec.rb +8 -4
  47. data/spec/watirspec/elements/date_field_spec.rb +18 -9
  48. data/spec/watirspec/elements/date_time_field_spec.rb +3 -4
  49. data/spec/watirspec/elements/div_spec.rb +62 -54
  50. data/spec/watirspec/elements/element_spec.rb +60 -78
  51. data/spec/watirspec/elements/elements_spec.rb +12 -3
  52. data/spec/watirspec/elements/filefield_spec.rb +25 -50
  53. data/spec/watirspec/elements/form_spec.rb +6 -8
  54. data/spec/watirspec/elements/frame_spec.rb +10 -13
  55. data/spec/watirspec/elements/iframe_spec.rb +17 -12
  56. data/spec/watirspec/elements/iframes_spec.rb +2 -2
  57. data/spec/watirspec/elements/link_spec.rb +18 -9
  58. data/spec/watirspec/elements/links_spec.rb +11 -3
  59. data/spec/watirspec/elements/option_spec.rb +15 -17
  60. data/spec/watirspec/elements/select_list_spec.rb +66 -80
  61. data/spec/watirspec/elements/text_field_spec.rb +8 -4
  62. data/spec/watirspec/elements/tr_spec.rb +0 -9
  63. data/spec/watirspec/html/forms_with_input_elements.html +1 -0
  64. data/spec/watirspec/html/iframes.html +3 -0
  65. data/spec/watirspec/html/non_control_elements.html +4 -4
  66. data/spec/watirspec/html/right_click.html +12 -0
  67. data/spec/watirspec/html/wait.html +1 -1
  68. data/spec/watirspec/relaxed_locate_spec.rb +16 -20
  69. data/spec/watirspec/support/rspec_matchers.rb +7 -6
  70. data/spec/watirspec/user_editable_spec.rb +1 -1
  71. data/spec/watirspec/wait_spec.rb +13 -17
  72. data/spec/watirspec/window_switching_spec.rb +162 -163
  73. data/spec/watirspec_helper.rb +7 -5
  74. data/watir.gemspec +4 -5
  75. metadata +14 -16
  76. data/lib/watir/elements/area.rb +0 -10
@@ -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
@@ -13,7 +13,7 @@ describe 'Buttons' do
13
13
 
14
14
  describe '#length' do
15
15
  it 'returns the number of buttons' do
16
- expect(browser.buttons.length).to eq 10
16
+ expect(browser.buttons.length).to eq 11
17
17
  end
18
18
  end
19
19
 
@@ -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
- expect(browser.checkbox(label: /some visible some hidden/)).to_not exist
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
- expect {
46
- expect(browser.checkbox(label: /some visible$/)).to exist
47
- }.to have_deprecated_text_regexp
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
- it 'respects date fields types' do
28
- expect(browser.date_field.type).to eq('date')
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
- describe '#type' do
75
- it 'returns the type attribute if the date field exists' do
76
- expect(browser.date_field(id: 'html5_date').type).to eq 'date'
77
- end
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
- it "raises UnknownObjectException if the date field doesn't exist" do
80
- expect { browser.date_field(index: 1337).type }.to raise_unknown_object_exception
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
- # Firefox validates attribute "type" as "text" not "datetime-local"
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://bugzilla.mozilla.org/show_bug.cgi?id=1424984', :firefox do
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://bugzilla.mozilla.org/show_bug.cgi?id=1424984', :firefox do
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
- not_compliant_on :safari do
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
- it 'throws deprecation when no longer matched by text content' do
141
- expect { browser.div(text: /some visible$/).locate }.to have_deprecated_text_regexp
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
- it 'does not locate entire content with regular expressions' do
154
- expect(browser.div(text: /some visible some hidden/)).to_not exist
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
- not_compliant_on :headless do
162
- describe '#click' do
163
- it 'fires events when clicked' do
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
- it 'raises UnknownObjectException if the element does not exist' do
170
- expect { browser.div(id: 'no_such_id').click }.to raise_unknown_object_exception
171
- expect { browser.div(title: 'no_such_title').click }.to raise_unknown_object_exception
172
- expect { browser.div(index: 1337).click }.to raise_unknown_object_exception
173
- expect { browser.div(xpath: "//div[@id='no_such_id']").click }.to raise_unknown_object_exception
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
- it 'includes custom message if element with a custom attribute does not exist' do
177
- message = /Watir treated \[\"custom_attribute\"\] as a non-HTML compliant attribute, ensure that was intended/
178
- expect { browser.div(custom_attribute: 'not_there').click }.to raise_unknown_object_exception(message)
179
- end
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
- describe '#click!' do
183
- it 'fires events when clicked' do
184
- expect(browser.div(id: 'best_language').text).to_not eq 'Ruby!'
185
- browser.div(id: 'best_language').click!
186
- expect(browser.div(id: 'best_language').text).to eq 'Ruby!'
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
- it 'raises UnknownObjectException if the element does not exist' do
190
- expect { browser.div(id: 'no_such_id').click! }.to raise_unknown_object_exception
191
- expect { browser.div(title: 'no_such_title').click! }.to raise_unknown_object_exception
192
- expect { browser.div(index: 1337).click! }.to raise_unknown_object_exception
193
- expect { browser.div(xpath: "//div[@id='no_such_id']").click! }.to raise_unknown_object_exception
194
- end
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
- not_compliant_on :safari do
199
- bug 'MoveTargetOutOfBoundsError', :firefox do
200
- describe '#double_click' do
201
- it 'fires the ondblclick event' do
202
- browser.div(id: 'html_test').double_click
203
- expect(messages).to include('double clicked')
204
- end
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
- describe '#double_click!' do
208
- it 'fires the ondblclick event' do
209
- browser.div(id: 'html_test').double_click!
210
- expect(messages).to include('double clicked')
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
- not_compliant_on :firefox do
216
- describe '#right_click' do
217
- it 'fires the oncontextmenu event' do
218
- browser.goto(WatirSpec.url_for('right_click.html'))
219
- browser.div(id: 'click').right_click
220
- expect(messages.first).to eq 'right-clicked'
221
- end
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\:(Fixnum|Integer)/
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:(Fixnum|Integer)/
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 \[\"visible_element\"\]/
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 \[\"visible_element\"\]/
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 'raises UnknownObjectException exception if the element is stale' do
247
+ it 'handles staleness' do
242
248
  element = browser.text_field(id: 'new_user_email').locate
243
249
 
244
- browser.refresh
250
+ allow(element).to receive(:stale?).and_return(true)
245
251
 
246
- expect(element).to be_stale
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 \[\"visible_element\"\]/
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 \[\"visible_element\"\]/
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 'element from a collection returns false when it becomes stale' do
310
+ it 'handles staleness in a collection' do
310
311
  element = browser.divs(id: 'text').first.locate
311
312
 
312
- browser.refresh
313
+ allow(element).to receive(:stale?).and_return(true)
313
314
 
314
- expect(element).to be_stale
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 'returns false if the element is stale' do
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
356
- element = browser.div(id: 'foo').locate
357
- browser.goto(WatirSpec.url_for('iframes.html'))
358
-
359
- expect { element.present? }.to_not have_deprecated_stale_present
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
341
+ it 'handles staleness' do
364
342
  element = browser.div(id: 'foo').locate
365
343
 
366
- browser.refresh
367
-
368
- expect(element).to be_stale
344
+ allow(element).to receive(:stale?).and_return(true)
369
345
 
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', :chrome do
539
- not_compliant_on :safari, :firefox do
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 'https://github.com/mozilla/geckodriver/issues/1375', :firefox do
566
- it 'accepts modifiers' do
567
- begin
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, :safari do
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
- not_compliant_on %i[remote firefox] do
707
- describe '#scroll_into_view' do
708
- it 'scrolls element into view' do
709
- el = browser.button(name: 'new_user_image')
710
- element_center = el.center['y']
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
- bottom_viewport_script = 'return window.pageYOffset + window.innerHeight'
713
- expect(browser.execute_script(bottom_viewport_script)).to be < element_center
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
- expect(browser.execute_script(bottom_viewport_script)).to be > element_center
718
- end
695
+ expect(browser.execute_script(bottom_viewport_script)).to be > element_center
719
696
  end
720
697
  end
721
698
 
@@ -902,31 +879,34 @@ describe 'Element' do
902
879
  describe '#obscured?' do
903
880
  before { browser.goto WatirSpec.url_for('obscured.html') }
904
881
 
905
- it 'returns false if element\'s center is not covered' do
882
+ it 'returns false if element center is not covered' do
906
883
  btn = browser.button(id: 'not_obscured')
907
884
  expect(btn).not_to be_obscured
908
885
  expect { btn.click }.not_to raise_exception
909
886
  end
910
887
 
911
- it 'returns false if element\'s center is covered by its descendant' do
888
+ it 'returns false if element center is covered by its descendant' do
912
889
  btn = browser.button(id: 'has_descendant')
913
890
  expect(btn).not_to be_obscured
914
891
  expect { btn.click }.not_to raise_exception
915
892
  end
916
893
 
917
- it 'returns true if element\'s center is covered by a non-descendant' do
894
+ it 'returns true if element center is covered by a non-descendant' do
918
895
  btn = browser.button(id: 'obscured')
919
896
  expect(btn).to be_obscured
920
- not_compliant_on :chrome do
897
+ not_compliant_on :chrome, :safari do
921
898
  expect { btn.click }.to raise_exception(Selenium::WebDriver::Error::ElementClickInterceptedError)
922
899
  end
923
900
  compliant_on :chrome do
924
- expect { btn.click }.to raise_exception(Selenium::WebDriver::Error::UnknownError)
901
+ expect { btn.click }.to raise_exception(Selenium::WebDriver::Error::ElementClickInterceptedError)
902
+ end
903
+ compliant_on :safari do
904
+ expect { btn.click }.to raise_exception(Selenium::WebDriver::Error::WebDriverError)
925
905
  end
926
906
  end
927
907
 
928
908
  not_compliant_on %i[firefox appveyor] do
929
- it 'returns false if element\'s center is surrounded by non-descendants' do
909
+ it 'returns false if element center is surrounded by non-descendants' do
930
910
  btn = browser.button(id: 'surrounded')
931
911
  expect(btn).not_to be_obscured
932
912
  expect { btn.click }.not_to raise_exception
@@ -945,10 +925,12 @@ describe 'Element' do
945
925
  expect { div.click }.not_to raise_exception
946
926
  end
947
927
 
948
- it 'returns true if element cannot be scrolled into view' do
949
- btn = browser.button(id: 'off_screen')
950
- expect(btn).to be_obscured
951
- expect { btn.click }.to raise_unknown_object_exception
928
+ bug 'Safari is throwing click intercepted here', :safari do
929
+ it 'returns true if element cannot be scrolled into view' do
930
+ btn = browser.button(id: 'off_screen')
931
+ expect(btn).to be_obscured
932
+ expect { btn.click }.to raise_unknown_object_exception
933
+ end
952
934
  end
953
935
 
954
936
  it 'returns true if element is hidden' do