capybara 3.29.0 → 3.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +203 -15
  3. data/README.md +13 -4
  4. data/lib/capybara/config.rb +24 -10
  5. data/lib/capybara/cucumber.rb +1 -1
  6. data/lib/capybara/driver/base.rb +8 -0
  7. data/lib/capybara/driver/node.rb +1 -1
  8. data/lib/capybara/dsl.rb +10 -2
  9. data/lib/capybara/helpers.rb +19 -2
  10. data/lib/capybara/minitest/spec.rb +156 -97
  11. data/lib/capybara/minitest.rb +232 -144
  12. data/lib/capybara/node/actions.rb +41 -37
  13. data/lib/capybara/node/base.rb +6 -6
  14. data/lib/capybara/node/document.rb +2 -2
  15. data/lib/capybara/node/document_matchers.rb +3 -3
  16. data/lib/capybara/node/element.rb +24 -21
  17. data/lib/capybara/node/finders.rb +25 -18
  18. data/lib/capybara/node/matchers.rb +72 -57
  19. data/lib/capybara/node/simple.rb +13 -3
  20. data/lib/capybara/queries/active_element_query.rb +18 -0
  21. data/lib/capybara/queries/ancestor_query.rb +4 -3
  22. data/lib/capybara/queries/base_query.rb +2 -1
  23. data/lib/capybara/queries/current_path_query.rb +14 -4
  24. data/lib/capybara/queries/selector_query.rb +71 -23
  25. data/lib/capybara/queries/sibling_query.rb +4 -3
  26. data/lib/capybara/queries/style_query.rb +1 -1
  27. data/lib/capybara/queries/text_query.rb +7 -1
  28. data/lib/capybara/rack_test/browser.rb +13 -4
  29. data/lib/capybara/rack_test/driver.rb +2 -1
  30. data/lib/capybara/rack_test/form.rb +2 -2
  31. data/lib/capybara/rack_test/node.rb +43 -15
  32. data/lib/capybara/registration_container.rb +44 -0
  33. data/lib/capybara/registrations/drivers.rb +18 -12
  34. data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
  35. data/lib/capybara/registrations/servers.rb +3 -2
  36. data/lib/capybara/result.rb +35 -15
  37. data/lib/capybara/rspec/matcher_proxies.rb +8 -8
  38. data/lib/capybara/rspec/matchers/base.rb +12 -6
  39. data/lib/capybara/rspec/matchers/count_sugar.rb +2 -1
  40. data/lib/capybara/rspec/matchers/have_ancestor.rb +4 -3
  41. data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
  42. data/lib/capybara/rspec/matchers/have_selector.rb +16 -8
  43. data/lib/capybara/rspec/matchers/have_sibling.rb +3 -3
  44. data/lib/capybara/rspec/matchers/have_text.rb +3 -3
  45. data/lib/capybara/rspec/matchers/have_title.rb +2 -2
  46. data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
  47. data/lib/capybara/rspec/matchers/match_style.rb +7 -2
  48. data/lib/capybara/rspec/matchers/spatial_sugar.rb +2 -1
  49. data/lib/capybara/rspec/matchers.rb +33 -32
  50. data/lib/capybara/rspec.rb +2 -0
  51. data/lib/capybara/selector/builders/css_builder.rb +2 -2
  52. data/lib/capybara/selector/builders/xpath_builder.rb +4 -2
  53. data/lib/capybara/selector/css.rb +2 -2
  54. data/lib/capybara/selector/definition/button.rb +35 -13
  55. data/lib/capybara/selector/definition/checkbox.rb +3 -3
  56. data/lib/capybara/selector/definition/css.rb +3 -1
  57. data/lib/capybara/selector/definition/datalist_input.rb +2 -2
  58. data/lib/capybara/selector/definition/datalist_option.rb +1 -1
  59. data/lib/capybara/selector/definition/element.rb +3 -2
  60. data/lib/capybara/selector/definition/field.rb +1 -1
  61. data/lib/capybara/selector/definition/file_field.rb +2 -2
  62. data/lib/capybara/selector/definition/fillable_field.rb +3 -3
  63. data/lib/capybara/selector/definition/label.rb +5 -3
  64. data/lib/capybara/selector/definition/link.rb +8 -0
  65. data/lib/capybara/selector/definition/radio_button.rb +3 -3
  66. data/lib/capybara/selector/definition/select.rb +33 -14
  67. data/lib/capybara/selector/definition/table.rb +6 -3
  68. data/lib/capybara/selector/definition/table_row.rb +2 -2
  69. data/lib/capybara/selector/definition.rb +14 -11
  70. data/lib/capybara/selector/filter_set.rb +17 -17
  71. data/lib/capybara/selector/filters/base.rb +6 -1
  72. data/lib/capybara/selector/filters/locator_filter.rb +1 -1
  73. data/lib/capybara/selector/selector.rb +13 -3
  74. data/lib/capybara/selector.rb +37 -19
  75. data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -1
  76. data/lib/capybara/selenium/atoms/src/getAttribute.js +1 -1
  77. data/lib/capybara/selenium/atoms/src/isDisplayed.js +1 -1
  78. data/lib/capybara/selenium/driver.rb +79 -16
  79. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +11 -13
  80. data/lib/capybara/selenium/driver_specializations/edge_driver.rb +10 -12
  81. data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +4 -4
  82. data/lib/capybara/selenium/extensions/find.rb +4 -4
  83. data/lib/capybara/selenium/extensions/html5_drag.rb +30 -13
  84. data/lib/capybara/selenium/extensions/scroll.rb +8 -10
  85. data/lib/capybara/selenium/logger_suppressor.rb +8 -2
  86. data/lib/capybara/selenium/node.rb +110 -26
  87. data/lib/capybara/selenium/nodes/chrome_node.rb +34 -19
  88. data/lib/capybara/selenium/nodes/edge_node.rb +5 -3
  89. data/lib/capybara/selenium/nodes/firefox_node.rb +11 -6
  90. data/lib/capybara/selenium/nodes/safari_node.rb +3 -3
  91. data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
  92. data/lib/capybara/selenium/patches/atoms.rb +4 -4
  93. data/lib/capybara/selenium/patches/logs.rb +7 -9
  94. data/lib/capybara/server/animation_disabler.rb +17 -6
  95. data/lib/capybara/server/checker.rb +1 -1
  96. data/lib/capybara/server/middleware.rb +22 -10
  97. data/lib/capybara/server.rb +15 -3
  98. data/lib/capybara/session/config.rb +9 -3
  99. data/lib/capybara/session/matchers.rb +11 -11
  100. data/lib/capybara/session.rb +73 -37
  101. data/lib/capybara/spec/public/test.js +75 -7
  102. data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
  103. data/lib/capybara/spec/session/active_element_spec.rb +31 -0
  104. data/lib/capybara/spec/session/all_spec.rb +62 -9
  105. data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
  106. data/lib/capybara/spec/session/assert_text_spec.rb +9 -5
  107. data/lib/capybara/spec/session/check_spec.rb +15 -0
  108. data/lib/capybara/spec/session/choose_spec.rb +6 -0
  109. data/lib/capybara/spec/session/click_button_spec.rb +16 -0
  110. data/lib/capybara/spec/session/click_link_or_button_spec.rb +9 -0
  111. data/lib/capybara/spec/session/current_url_spec.rb +11 -1
  112. data/lib/capybara/spec/session/fill_in_spec.rb +29 -0
  113. data/lib/capybara/spec/session/find_spec.rb +31 -8
  114. data/lib/capybara/spec/session/has_any_selectors_spec.rb +4 -0
  115. data/lib/capybara/spec/session/has_button_spec.rb +75 -0
  116. data/lib/capybara/spec/session/has_css_spec.rb +14 -10
  117. data/lib/capybara/spec/session/has_current_path_spec.rb +15 -2
  118. data/lib/capybara/spec/session/has_field_spec.rb +40 -0
  119. data/lib/capybara/spec/session/has_link_spec.rb +24 -0
  120. data/lib/capybara/spec/session/has_select_spec.rb +32 -4
  121. data/lib/capybara/spec/session/has_selector_spec.rb +4 -4
  122. data/lib/capybara/spec/session/has_table_spec.rb +51 -5
  123. data/lib/capybara/spec/session/has_text_spec.rb +25 -1
  124. data/lib/capybara/spec/session/html_spec.rb +1 -1
  125. data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
  126. data/lib/capybara/spec/session/node_spec.rb +184 -33
  127. data/lib/capybara/spec/session/refresh_spec.rb +2 -1
  128. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
  129. data/lib/capybara/spec/session/save_page_spec.rb +4 -4
  130. data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
  131. data/lib/capybara/spec/session/scroll_spec.rb +4 -4
  132. data/lib/capybara/spec/session/selectors_spec.rb +15 -2
  133. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
  134. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
  135. data/lib/capybara/spec/session/window/window_spec.rb +8 -8
  136. data/lib/capybara/spec/session/window/windows_spec.rb +1 -1
  137. data/lib/capybara/spec/spec_helper.rb +17 -17
  138. data/lib/capybara/spec/test_app.rb +40 -29
  139. data/lib/capybara/spec/views/animated.erb +1 -1
  140. data/lib/capybara/spec/views/form.erb +52 -6
  141. data/lib/capybara/spec/views/frame_child.erb +1 -1
  142. data/lib/capybara/spec/views/frame_one.erb +1 -1
  143. data/lib/capybara/spec/views/frame_parent.erb +1 -1
  144. data/lib/capybara/spec/views/frame_two.erb +1 -1
  145. data/lib/capybara/spec/views/initial_alert.erb +2 -1
  146. data/lib/capybara/spec/views/layout.erb +10 -0
  147. data/lib/capybara/spec/views/obscured.erb +1 -1
  148. data/lib/capybara/spec/views/offset.erb +2 -1
  149. data/lib/capybara/spec/views/path.erb +2 -2
  150. data/lib/capybara/spec/views/popup_one.erb +1 -1
  151. data/lib/capybara/spec/views/popup_two.erb +1 -1
  152. data/lib/capybara/spec/views/react.erb +2 -2
  153. data/lib/capybara/spec/views/scroll.erb +2 -1
  154. data/lib/capybara/spec/views/spatial.erb +1 -1
  155. data/lib/capybara/spec/views/with_animation.erb +10 -3
  156. data/lib/capybara/spec/views/with_base_tag.erb +2 -2
  157. data/lib/capybara/spec/views/with_dragula.erb +5 -3
  158. data/lib/capybara/spec/views/with_fixed_header_footer.erb +2 -1
  159. data/lib/capybara/spec/views/with_hover.erb +2 -2
  160. data/lib/capybara/spec/views/with_html.erb +3 -3
  161. data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
  162. data/lib/capybara/spec/views/with_js.erb +5 -3
  163. data/lib/capybara/spec/views/with_jstree.erb +1 -1
  164. data/lib/capybara/spec/views/with_namespace.erb +1 -0
  165. data/lib/capybara/spec/views/with_slow_unload.erb +2 -1
  166. data/lib/capybara/spec/views/with_sortable_js.erb +3 -3
  167. data/lib/capybara/spec/views/with_unload_alert.erb +1 -0
  168. data/lib/capybara/spec/views/with_windows.erb +1 -1
  169. data/lib/capybara/spec/views/within_frames.erb +1 -1
  170. data/lib/capybara/version.rb +1 -1
  171. data/lib/capybara/window.rb +3 -7
  172. data/lib/capybara.rb +35 -29
  173. data/spec/basic_node_spec.rb +25 -11
  174. data/spec/capybara_spec.rb +1 -1
  175. data/spec/dsl_spec.rb +16 -3
  176. data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
  177. data/spec/minitest_spec.rb +3 -2
  178. data/spec/minitest_spec_spec.rb +46 -46
  179. data/spec/rack_test_spec.rb +37 -11
  180. data/spec/regexp_dissassembler_spec.rb +40 -36
  181. data/spec/result_spec.rb +42 -32
  182. data/spec/rspec/features_spec.rb +5 -2
  183. data/spec/rspec/scenarios_spec.rb +4 -0
  184. data/spec/rspec/shared_spec_matchers.rb +68 -56
  185. data/spec/rspec_spec.rb +8 -4
  186. data/spec/selector_spec.rb +17 -2
  187. data/spec/selenium_spec_chrome.rb +48 -25
  188. data/spec/selenium_spec_chrome_remote.rb +13 -6
  189. data/spec/selenium_spec_firefox.rb +25 -17
  190. data/spec/selenium_spec_firefox_remote.rb +2 -2
  191. data/spec/selenium_spec_ie.rb +3 -6
  192. data/spec/selenium_spec_safari.rb +27 -19
  193. data/spec/server_spec.rb +84 -31
  194. data/spec/session_spec.rb +1 -1
  195. data/spec/shared_selenium_node.rb +21 -7
  196. data/spec/shared_selenium_session.rb +114 -19
  197. data/spec/spec_helper.rb +1 -1
  198. metadata +78 -21
  199. data/lib/capybara/spec/session/source_spec.rb +0 -0
  200. data/lib/capybara/spec/views/with_title.erb +0 -5
@@ -72,9 +72,8 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
72
72
  end
73
73
  end
74
74
 
75
- context '#fill_in_with empty string and no options' do
75
+ describe '#fill_in_with empty string and no options' do
76
76
  it 'should trigger change when clearing a field' do
77
- pending "safaridriver doesn't trigger change for clear" if safari?(session)
78
77
  session.visit('/with_js')
79
78
  session.fill_in('with_change_event', with: '')
80
79
  # click outside the field to trigger the change event
@@ -83,7 +82,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
83
82
  end
84
83
  end
85
84
 
86
- context '#fill_in with { :clear => :backspace } fill_option', requires: [:js] do
85
+ describe '#fill_in with { :clear => :backspace } fill_option', requires: [:js] do
87
86
  before do
88
87
  # Firefox has an issue with change events if the main window doesn't think it's focused
89
88
  session.execute_script('window.focus()')
@@ -150,7 +149,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
150
149
  end
151
150
  end
152
151
 
153
- context '#fill_in with { clear: :none } fill_options' do
152
+ describe '#fill_in with { clear: :none } fill_options' do
154
153
  it 'should append to content in a field' do
155
154
  pending 'Safari overwrites by default - need to figure out a workaround' if safari?(session)
156
155
 
@@ -160,9 +159,18 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
160
159
  fill_options: { clear: :none })
161
160
  expect(session.find(:fillable_field, 'form_first_name').value).to eq('JohnHarry')
162
161
  end
162
+
163
+ it 'works with rapid fill' do
164
+ pending 'Safari overwrites by default - need to figure out a workaround' if safari?(session)
165
+
166
+ long_string = (0...60).map { |i| ((i % 26) + 65).chr }.join
167
+ session.visit('/form')
168
+ session.fill_in('form_first_name', with: long_string, fill_options: { clear: :none })
169
+ expect(session.find(:fillable_field, 'form_first_name').value).to eq("John#{long_string}")
170
+ end
163
171
  end
164
172
 
165
- context '#fill_in with Date' do
173
+ describe '#fill_in with Date' do
166
174
  before do
167
175
  session.visit('/form')
168
176
  session.find(:css, '#form_date').execute_script <<-JS
@@ -179,14 +187,12 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
179
187
 
180
188
  it 'should generate standard events on changing value' do
181
189
  pending "IE 11 doesn't support date input type" if ie?(session)
182
- pending "Safari doesn't support date input type" if safari?(session)
183
190
  session.fill_in('form_date', with: Date.today)
184
191
  expect(session.evaluate_script('window.capybara_formDateFiredEvents')).to eq %w[focus input change]
185
192
  end
186
193
 
187
194
  it 'should not generate input and change events if the value is not changed' do
188
195
  pending "IE 11 doesn't support date input type" if ie?(session)
189
- pending "Safari doesn't support date input type" if safari?(session)
190
196
  session.fill_in('form_date', with: Date.today)
191
197
  session.fill_in('form_date', with: Date.today)
192
198
  # Chrome adds an extra focus for some reason - ok for now
@@ -194,7 +200,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
194
200
  end
195
201
  end
196
202
 
197
- context '#fill_in with { clear: Array } fill_options' do
203
+ describe '#fill_in with { clear: Array } fill_options' do
198
204
  it 'should pass the array through to the element' do
199
205
  # this is mainly for use with [[:control, 'a'], :backspace] - however since that is platform dependant I'm testing with something less useful
200
206
  session.visit('/form')
@@ -205,6 +211,26 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
205
211
  end
206
212
  end
207
213
 
214
+ describe '#fill_in with Emoji' do
215
+ it 'sends emojis' do
216
+ session.visit('/form')
217
+ session.fill_in('form_first_name', with: 'a😀cd😴 🛌🏽🇵🇹 e🤾🏽‍♀️f')
218
+ expect(session.find(:fillable_field, 'form_first_name').value).to eq('a😀cd😴 🛌🏽🇵🇹 e🤾🏽‍♀️f')
219
+ end
220
+ end
221
+
222
+ describe '#send_keys' do
223
+ it 'defaults to sending keys to the active_element' do
224
+ session.visit('/form')
225
+
226
+ expect(session.active_element).to match_selector(:css, 'body')
227
+
228
+ session.send_keys(:tab)
229
+
230
+ expect(session.active_element).to match_selector(:css, '[tabindex="1"]')
231
+ end
232
+ end
233
+
208
234
  describe '#path' do
209
235
  it 'returns xpath' do
210
236
  # this is here because it is testing for an XPath that is specific to the algorithm used in the selenium driver
@@ -299,8 +325,9 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
299
325
  describe 'Element#click' do
300
326
  it 'should handle fixed headers/footers' do
301
327
  session.visit('/with_fixed_header_footer')
302
- # session.click_link('Go to root')
303
- session.find(:link, 'Go to root').click
328
+ session.using_wait_time(2) do
329
+ session.find(:link, 'Go to root').click
330
+ end
304
331
  expect(session).to have_current_path('/')
305
332
  end
306
333
  end
@@ -351,6 +378,12 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
351
378
  @animation_session = Capybara::Session.new(session.mode, TestApp.new)
352
379
  end
353
380
 
381
+ it 'should add CSS to the <head> element' do
382
+ @animation_session.visit('with_animation')
383
+
384
+ expect(@animation_session).to have_selector(:css, 'head > style', text: 'transition: none', visible: :hidden)
385
+ end
386
+
354
387
  it 'should disable CSS transitions' do
355
388
  @animation_session.visit('with_animation')
356
389
  @animation_session.click_link('transition me away')
@@ -359,15 +392,64 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
359
392
 
360
393
  it 'should disable CSS animations (set to 0s)' do
361
394
  @animation_session.visit('with_animation')
395
+ sleep 1
362
396
  @animation_session.click_link('animate me away')
363
397
  expect(@animation_session).to have_no_link('animate me away', wait: 0.5)
364
398
  end
365
399
 
366
400
  it 'should disable CSS animations on pseudo elements (set to 0s)' do
367
401
  @animation_session.visit('with_animation')
402
+ sleep 1
368
403
  @animation_session.find_link('animate me away').right_click
369
404
  expect(@animation_session).to have_content('Animation Ended', wait: 0.1)
370
405
  end
406
+
407
+ it 'should scroll the page instantly', requires: [:js] do
408
+ @animation_session.visit('with_animation')
409
+ scroll_y = @animation_session.evaluate_script(<<~JS)
410
+ (function(){
411
+ window.scrollTo(0,500);
412
+ return window.scrollY;
413
+ })()
414
+ JS
415
+ expect(scroll_y).to eq 500
416
+ end
417
+
418
+ it 'should scroll the page instantly without jquery animation', requires: [:js] do
419
+ @animation_session.visit('with_jquery_animation')
420
+ @animation_session.click_link('scroll top 500')
421
+ scroll_y = @animation_session.evaluate_script('window.scrollY')
422
+ expect(scroll_y).to eq 500
423
+ end
424
+ end
425
+
426
+ context 'when set to `false`' do
427
+ before(:context) do # rubocop:disable RSpec/BeforeAfterAll
428
+ skip "Safari doesn't support multiple sessions" if safari?(session)
429
+ # NOTE: Although Capybara.SpecHelper.reset! sets Capybara.disable_animation to false,
430
+ # it doesn't affect any of these tests because the settings are applied per-session
431
+ Capybara.disable_animation = false
432
+ @animation_session = Capybara::Session.new(session.mode, TestApp.new)
433
+ end
434
+
435
+ it 'should scroll the page with a smooth animation', requires: [:js] do
436
+ @animation_session.visit('with_animation')
437
+ scroll_y = @animation_session.evaluate_script(<<~JS)
438
+ (function(){
439
+ window.scrollTo(0,500);
440
+ return window.scrollY;
441
+ })()
442
+ JS
443
+ # measured over 0.5 seconds: 0, 75, 282, 478, 500
444
+ expect(scroll_y).to be < 500
445
+ end
446
+
447
+ it 'should scroll the page with jquery animation', requires: [:js] do
448
+ @animation_session.visit('with_jquery_animation')
449
+ @animation_session.click_link('scroll top 500')
450
+ scroll_y = @animation_session.evaluate_script('window.scrollY')
451
+ expect(scroll_y).to be < 500
452
+ end
371
453
  end
372
454
 
373
455
  context 'if we pass in css that matches elements' do
@@ -381,12 +463,14 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
381
463
 
382
464
  it 'should disable CSS transitions' do
383
465
  @animation_session_with_matching_css.visit('with_animation')
466
+ sleep 1
384
467
  @animation_session_with_matching_css.click_link('transition me away')
385
468
  expect(@animation_session_with_matching_css).to have_no_link('transition me away', wait: 0.5)
386
469
  end
387
470
 
388
471
  it 'should disable CSS animations' do
389
472
  @animation_session_with_matching_css.visit('with_animation')
473
+ sleep 1
390
474
  @animation_session_with_matching_css.click_link('animate me away')
391
475
  expect(@animation_session_with_matching_css).to have_no_link('animate me away', wait: 0.5)
392
476
  end
@@ -403,6 +487,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
403
487
 
404
488
  it 'should not disable CSS transitions' do
405
489
  @animation_session_without_matching_css.visit('with_animation')
490
+ sleep 1
406
491
  @animation_session_without_matching_css.click_link('transition me away')
407
492
  sleep 0.5 # Wait long enough for click to have been processed
408
493
  expect(@animation_session_without_matching_css).to have_link('transition me away', wait: false)
@@ -411,6 +496,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
411
496
 
412
497
  it 'should not disable CSS animations' do
413
498
  @animation_session_without_matching_css.visit('with_animation')
499
+ sleep 1
414
500
  @animation_session_without_matching_css.click_link('animate me away')
415
501
  sleep 0.5 # Wait long enough for click to have been processed
416
502
  expect(@animation_session_without_matching_css).to have_link('animate me away', wait: false)
@@ -424,15 +510,15 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
424
510
  it 'can find html5 svg elements' do
425
511
  session.visit('with_html5_svg')
426
512
  expect(session).to have_selector(:element, :svg)
427
- expect(session).to have_selector(:element, :rect, visible: true)
513
+ expect(session).to have_selector(:element, :rect, visible: :visible)
428
514
  expect(session).to have_selector(:element, :circle)
429
515
  expect(session).to have_selector(:element, :linearGradient, visible: :all)
430
516
  end
431
517
 
432
518
  it 'can query attributes with strange characters' do
433
519
  session.visit('/form')
434
- expect(session).to have_selector(:element, "{custom}": true)
435
- expect(session).to have_selector(:element, "{custom}": 'abcdef')
520
+ expect(session).to have_selector(:element, '{custom}': true)
521
+ expect(session).to have_selector(:element, '{custom}': 'abcdef')
436
522
  end
437
523
  end
438
524
 
@@ -440,21 +526,30 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
440
526
  context 'controlled components' do
441
527
  it 'can set and clear a text field' do
442
528
  skip "This test doesn't support older browsers" if ie?(session)
443
- # session.visit 'https://reactjs.org/docs/forms.html'
444
- # session.all(:css, 'h2#controlled-components ~ p a', text: 'Try it on CodePen')[0].click
445
- # copied into local view
529
+
446
530
  session.visit 'react'
447
- # Not necessary when accessed locally
448
- # session.within_frame(:css, 'iframe.result-iframe:not([src=""])', wait: 10) do
531
+
449
532
  session.fill_in('Name:', with: 'abc')
450
533
  session.accept_prompt 'A name was submitted: abc' do
451
534
  session.click_button('Submit')
452
535
  end
536
+
453
537
  session.fill_in('Name:', with: '')
454
538
  session.accept_prompt(/A name was submitted: $/) do
455
539
  session.click_button('Submit')
456
540
  end
457
- # end
541
+ end
542
+
543
+ it 'works with rapid fill' do
544
+ skip "This test doesn't support older browsers" if ie?(session)
545
+
546
+ session.visit 'react'
547
+ long_string = (0...60).map { |i| ((i % 26) + 65).chr }.join
548
+
549
+ session.fill_in('Name:', with: long_string)
550
+ session.accept_prompt "A name was submitted: #{long_string}" do
551
+ session.click_button('Submit')
552
+ end
458
553
  end
459
554
  end
460
555
  end
data/spec/spec_helper.rb CHANGED
@@ -46,7 +46,7 @@ module Capybara
46
46
  end
47
47
 
48
48
  def edge?(session)
49
- browser_name(session).match?(/^edge/)
49
+ browser_name(session).to_s.start_with?('edge')
50
50
  end
51
51
 
52
52
  def legacy_edge?(session)
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.29.0
4
+ version: 3.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Walpole
8
8
  - Jonas Nicklas
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
- cert_chain:
12
- - gem-public_cert.pem
13
- date: 2019-09-02 00:00:00.000000000 Z
11
+ cert_chain: []
12
+ date: 2021-10-25 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: addressable
@@ -26,6 +25,20 @@ dependencies:
26
25
  - - ">="
27
26
  - !ruby/object:Gem::Version
28
27
  version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: matrix
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
29
42
  - !ruby/object:Gem::Dependency
30
43
  name: mini_mime
31
44
  requirement: !ruby/object:Gem::Requirement
@@ -86,16 +99,22 @@ dependencies:
86
99
  name: regexp_parser
87
100
  requirement: !ruby/object:Gem::Requirement
88
101
  requirements:
89
- - - "~>"
102
+ - - ">="
90
103
  - !ruby/object:Gem::Version
91
104
  version: '1.5'
105
+ - - "<"
106
+ - !ruby/object:Gem::Version
107
+ version: '3.0'
92
108
  type: :runtime
93
109
  prerelease: false
94
110
  version_requirements: !ruby/object:Gem::Requirement
95
111
  requirements:
96
- - - "~>"
112
+ - - ">="
97
113
  - !ruby/object:Gem::Version
98
114
  version: '1.5'
115
+ - - "<"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
99
118
  - !ruby/object:Gem::Dependency
100
119
  name: xpath
101
120
  requirement: !ruby/object:Gem::Requirement
@@ -270,16 +289,16 @@ dependencies:
270
289
  requirements:
271
290
  - - "~>"
272
291
  - !ruby/object:Gem::Version
273
- version: '0.72'
292
+ version: '1.1'
274
293
  type: :development
275
294
  prerelease: false
276
295
  version_requirements: !ruby/object:Gem::Requirement
277
296
  requirements:
278
297
  - - "~>"
279
298
  - !ruby/object:Gem::Version
280
- version: '0.72'
299
+ version: '1.1'
281
300
  - !ruby/object:Gem::Dependency
282
- name: rubocop-performance
301
+ name: rubocop-minitest
283
302
  requirement: !ruby/object:Gem::Requirement
284
303
  requirements:
285
304
  - - ">="
@@ -293,7 +312,7 @@ dependencies:
293
312
  - !ruby/object:Gem::Version
294
313
  version: '0'
295
314
  - !ruby/object:Gem::Dependency
296
- name: rubocop-rspec
315
+ name: rubocop-performance
297
316
  requirement: !ruby/object:Gem::Requirement
298
317
  requirements:
299
318
  - - ">="
@@ -307,7 +326,7 @@ dependencies:
307
326
  - !ruby/object:Gem::Version
308
327
  version: '0'
309
328
  - !ruby/object:Gem::Dependency
310
- name: sauce_whisk
329
+ name: rubocop-rake
311
330
  requirement: !ruby/object:Gem::Requirement
312
331
  requirements:
313
332
  - - ">="
@@ -321,19 +340,33 @@ dependencies:
321
340
  - !ruby/object:Gem::Version
322
341
  version: '0'
323
342
  - !ruby/object:Gem::Dependency
324
- name: selenium-webdriver
343
+ name: rubocop-rspec
325
344
  requirement: !ruby/object:Gem::Requirement
326
345
  requirements:
327
346
  - - "~>"
328
347
  - !ruby/object:Gem::Version
329
- version: '3.5'
348
+ version: '2.0'
330
349
  type: :development
331
350
  prerelease: false
332
351
  version_requirements: !ruby/object:Gem::Requirement
333
352
  requirements:
334
353
  - - "~>"
335
354
  - !ruby/object:Gem::Version
336
- version: '3.5'
355
+ version: '2.0'
356
+ - !ruby/object:Gem::Dependency
357
+ name: sauce_whisk
358
+ requirement: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - ">="
361
+ - !ruby/object:Gem::Version
362
+ version: '0'
363
+ type: :development
364
+ prerelease: false
365
+ version_requirements: !ruby/object:Gem::Requirement
366
+ requirements:
367
+ - - ">="
368
+ - !ruby/object:Gem::Version
369
+ version: '0'
337
370
  - !ruby/object:Gem::Dependency
338
371
  name: selenium_statistics
339
372
  requirement: !ruby/object:Gem::Requirement
@@ -348,6 +381,26 @@ dependencies:
348
381
  - - ">="
349
382
  - !ruby/object:Gem::Version
350
383
  version: '0'
384
+ - !ruby/object:Gem::Dependency
385
+ name: selenium-webdriver
386
+ requirement: !ruby/object:Gem::Requirement
387
+ requirements:
388
+ - - ">="
389
+ - !ruby/object:Gem::Version
390
+ version: 3.142.7
391
+ - - "<"
392
+ - !ruby/object:Gem::Version
393
+ version: '5.0'
394
+ type: :development
395
+ prerelease: false
396
+ version_requirements: !ruby/object:Gem::Requirement
397
+ requirements:
398
+ - - ">="
399
+ - !ruby/object:Gem::Version
400
+ version: 3.142.7
401
+ - - "<"
402
+ - !ruby/object:Gem::Version
403
+ version: '5.0'
351
404
  - !ruby/object:Gem::Dependency
352
405
  name: sinatra
353
406
  requirement: !ruby/object:Gem::Requirement
@@ -434,6 +487,7 @@ files:
434
487
  - lib/capybara/node/finders.rb
435
488
  - lib/capybara/node/matchers.rb
436
489
  - lib/capybara/node/simple.rb
490
+ - lib/capybara/queries/active_element_query.rb
437
491
  - lib/capybara/queries/ancestor_query.rb
438
492
  - lib/capybara/queries/base_query.rb
439
493
  - lib/capybara/queries/current_path_query.rb
@@ -450,6 +504,7 @@ files:
450
504
  - lib/capybara/rack_test/form.rb
451
505
  - lib/capybara/rack_test/node.rb
452
506
  - lib/capybara/rails.rb
507
+ - lib/capybara/registration_container.rb
453
508
  - lib/capybara/registrations/drivers.rb
454
509
  - lib/capybara/registrations/patches/puma_ssl.rb
455
510
  - lib/capybara/registrations/servers.rb
@@ -528,6 +583,7 @@ files:
528
583
  - lib/capybara/selenium/nodes/firefox_node.rb
529
584
  - lib/capybara/selenium/nodes/ie_node.rb
530
585
  - lib/capybara/selenium/nodes/safari_node.rb
586
+ - lib/capybara/selenium/patches/action_pauser.rb
531
587
  - lib/capybara/selenium/patches/atoms.rb
532
588
  - lib/capybara/selenium/patches/is_displayed.rb
533
589
  - lib/capybara/selenium/patches/logs.rb
@@ -551,6 +607,7 @@ files:
551
607
  - lib/capybara/spec/session/accept_alert_spec.rb
552
608
  - lib/capybara/spec/session/accept_confirm_spec.rb
553
609
  - lib/capybara/spec/session/accept_prompt_spec.rb
610
+ - lib/capybara/spec/session/active_element_spec.rb
554
611
  - lib/capybara/spec/session/all_spec.rb
555
612
  - lib/capybara/spec/session/ancestor_spec.rb
556
613
  - lib/capybara/spec/session/assert_all_of_selectors_spec.rb
@@ -623,7 +680,6 @@ files:
623
680
  - lib/capybara/spec/session/select_spec.rb
624
681
  - lib/capybara/spec/session/selectors_spec.rb
625
682
  - lib/capybara/spec/session/sibling_spec.rb
626
- - lib/capybara/spec/session/source_spec.rb
627
683
  - lib/capybara/spec/session/text_spec.rb
628
684
  - lib/capybara/spec/session/title_spec.rb
629
685
  - lib/capybara/spec/session/uncheck_spec.rb
@@ -651,6 +707,7 @@ files:
651
707
  - lib/capybara/spec/views/header_links.erb
652
708
  - lib/capybara/spec/views/host_links.erb
653
709
  - lib/capybara/spec/views/initial_alert.erb
710
+ - lib/capybara/spec/views/layout.erb
654
711
  - lib/capybara/spec/views/obscured.erb
655
712
  - lib/capybara/spec/views/offset.erb
656
713
  - lib/capybara/spec/views/path.erb
@@ -671,6 +728,7 @@ files:
671
728
  - lib/capybara/spec/views/with_html.erb
672
729
  - lib/capybara/spec/views/with_html5_svg.erb
673
730
  - lib/capybara/spec/views/with_html_entities.erb
731
+ - lib/capybara/spec/views/with_jquery_animation.erb
674
732
  - lib/capybara/spec/views/with_js.erb
675
733
  - lib/capybara/spec/views/with_jstree.erb
676
734
  - lib/capybara/spec/views/with_namespace.erb
@@ -679,7 +737,6 @@ files:
679
737
  - lib/capybara/spec/views/with_simple_html.erb
680
738
  - lib/capybara/spec/views/with_slow_unload.erb
681
739
  - lib/capybara/spec/views/with_sortable_js.erb
682
- - lib/capybara/spec/views/with_title.erb
683
740
  - lib/capybara/spec/views/with_unload_alert.erb
684
741
  - lib/capybara/spec/views/with_windows.erb
685
742
  - lib/capybara/spec/views/within_frames.erb
@@ -729,7 +786,7 @@ licenses:
729
786
  metadata:
730
787
  changelog_uri: https://github.com/teamcapybara/capybara/blob/master/History.md
731
788
  source_code_uri: https://github.com/teamcapybara/capybara
732
- post_install_message:
789
+ post_install_message:
733
790
  rdoc_options: []
734
791
  require_paths:
735
792
  - lib
@@ -737,15 +794,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
737
794
  requirements:
738
795
  - - ">="
739
796
  - !ruby/object:Gem::Version
740
- version: 2.4.0
797
+ version: 2.6.0
741
798
  required_rubygems_version: !ruby/object:Gem::Requirement
742
799
  requirements:
743
800
  - - ">="
744
801
  - !ruby/object:Gem::Version
745
802
  version: '0'
746
803
  requirements: []
747
- rubygems_version: 3.0.6
748
- signing_key:
804
+ rubygems_version: 3.2.29
805
+ signing_key:
749
806
  specification_version: 4
750
807
  summary: Capybara aims to simplify the process of integration testing Rack applications,
751
808
  such as Rails, Sinatra or Merb
File without changes
@@ -1,5 +0,0 @@
1
-
2
- <title>Test Title</title>
3
- <body>
4
- <svg><title>abcdefg</title></svg>
5
- </body>