capybara 3.30.0 → 3.35.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +153 -13
  3. data/README.md +9 -4
  4. data/lib/capybara.rb +18 -8
  5. data/lib/capybara/config.rb +4 -6
  6. data/lib/capybara/cucumber.rb +1 -1
  7. data/lib/capybara/driver/base.rb +4 -0
  8. data/lib/capybara/dsl.rb +10 -2
  9. data/lib/capybara/helpers.rb +25 -1
  10. data/lib/capybara/minitest.rb +232 -144
  11. data/lib/capybara/minitest/spec.rb +156 -97
  12. data/lib/capybara/node/actions.rb +16 -21
  13. data/lib/capybara/node/base.rb +6 -6
  14. data/lib/capybara/node/element.rb +14 -13
  15. data/lib/capybara/node/finders.rb +12 -7
  16. data/lib/capybara/node/matchers.rb +36 -27
  17. data/lib/capybara/node/simple.rb +6 -2
  18. data/lib/capybara/queries/ancestor_query.rb +1 -1
  19. data/lib/capybara/queries/base_query.rb +2 -1
  20. data/lib/capybara/queries/current_path_query.rb +14 -4
  21. data/lib/capybara/queries/selector_query.rb +40 -18
  22. data/lib/capybara/queries/sibling_query.rb +1 -1
  23. data/lib/capybara/queries/style_query.rb +1 -1
  24. data/lib/capybara/queries/text_query.rb +7 -1
  25. data/lib/capybara/rack_test/browser.rb +9 -3
  26. data/lib/capybara/rack_test/driver.rb +1 -0
  27. data/lib/capybara/rack_test/form.rb +1 -1
  28. data/lib/capybara/rack_test/node.rb +35 -10
  29. data/lib/capybara/registration_container.rb +44 -0
  30. data/lib/capybara/registrations/drivers.rb +18 -12
  31. data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
  32. data/lib/capybara/registrations/servers.rb +3 -2
  33. data/lib/capybara/result.rb +35 -15
  34. data/lib/capybara/rspec.rb +2 -0
  35. data/lib/capybara/rspec/matcher_proxies.rb +5 -5
  36. data/lib/capybara/rspec/matchers.rb +33 -32
  37. data/lib/capybara/rspec/matchers/base.rb +12 -6
  38. data/lib/capybara/rspec/matchers/count_sugar.rb +2 -1
  39. data/lib/capybara/rspec/matchers/have_ancestor.rb +4 -3
  40. data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
  41. data/lib/capybara/rspec/matchers/have_selector.rb +15 -7
  42. data/lib/capybara/rspec/matchers/have_sibling.rb +3 -3
  43. data/lib/capybara/rspec/matchers/have_text.rb +3 -3
  44. data/lib/capybara/rspec/matchers/have_title.rb +2 -2
  45. data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
  46. data/lib/capybara/rspec/matchers/match_style.rb +7 -2
  47. data/lib/capybara/rspec/matchers/spatial_sugar.rb +2 -1
  48. data/lib/capybara/selector.rb +14 -3
  49. data/lib/capybara/selector/builders/css_builder.rb +1 -1
  50. data/lib/capybara/selector/builders/xpath_builder.rb +3 -1
  51. data/lib/capybara/selector/definition.rb +11 -9
  52. data/lib/capybara/selector/definition/button.rb +26 -14
  53. data/lib/capybara/selector/definition/css.rb +1 -1
  54. data/lib/capybara/selector/definition/datalist_input.rb +1 -1
  55. data/lib/capybara/selector/definition/element.rb +2 -1
  56. data/lib/capybara/selector/definition/fillable_field.rb +1 -1
  57. data/lib/capybara/selector/definition/label.rb +2 -2
  58. data/lib/capybara/selector/definition/link.rb +8 -0
  59. data/lib/capybara/selector/definition/select.rb +32 -13
  60. data/lib/capybara/selector/definition/table.rb +1 -1
  61. data/lib/capybara/selector/definition/table_row.rb +2 -2
  62. data/lib/capybara/selector/filter_set.rb +2 -2
  63. data/lib/capybara/selector/selector.rb +9 -1
  64. data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -1
  65. data/lib/capybara/selenium/atoms/src/getAttribute.js +1 -1
  66. data/lib/capybara/selenium/atoms/src/isDisplayed.js +1 -1
  67. data/lib/capybara/selenium/driver.rb +52 -7
  68. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +10 -12
  69. data/lib/capybara/selenium/driver_specializations/edge_driver.rb +9 -11
  70. data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +3 -3
  71. data/lib/capybara/selenium/extensions/find.rb +4 -4
  72. data/lib/capybara/selenium/extensions/html5_drag.rb +24 -8
  73. data/lib/capybara/selenium/extensions/scroll.rb +8 -10
  74. data/lib/capybara/selenium/logger_suppressor.rb +8 -2
  75. data/lib/capybara/selenium/node.rb +96 -16
  76. data/lib/capybara/selenium/nodes/chrome_node.rb +27 -16
  77. data/lib/capybara/selenium/nodes/edge_node.rb +1 -1
  78. data/lib/capybara/selenium/nodes/firefox_node.rb +9 -4
  79. data/lib/capybara/selenium/nodes/safari_node.rb +1 -1
  80. data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
  81. data/lib/capybara/selenium/patches/atoms.rb +4 -4
  82. data/lib/capybara/selenium/patches/logs.rb +7 -9
  83. data/lib/capybara/server/animation_disabler.rb +8 -3
  84. data/lib/capybara/server/middleware.rb +4 -2
  85. data/lib/capybara/session.rb +53 -29
  86. data/lib/capybara/session/config.rb +3 -1
  87. data/lib/capybara/session/matchers.rb +11 -11
  88. data/lib/capybara/spec/public/test.js +64 -7
  89. data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
  90. data/lib/capybara/spec/session/all_spec.rb +45 -5
  91. data/lib/capybara/spec/session/assert_text_spec.rb +5 -5
  92. data/lib/capybara/spec/session/check_spec.rb +6 -0
  93. data/lib/capybara/spec/session/click_button_spec.rb +11 -0
  94. data/lib/capybara/spec/session/click_link_or_button_spec.rb +9 -0
  95. data/lib/capybara/spec/session/current_url_spec.rb +11 -1
  96. data/lib/capybara/spec/session/fill_in_spec.rb +29 -0
  97. data/lib/capybara/spec/session/find_spec.rb +11 -8
  98. data/lib/capybara/spec/session/has_button_spec.rb +51 -0
  99. data/lib/capybara/spec/session/has_css_spec.rb +14 -10
  100. data/lib/capybara/spec/session/has_current_path_spec.rb +15 -2
  101. data/lib/capybara/spec/session/has_field_spec.rb +16 -0
  102. data/lib/capybara/spec/session/has_select_spec.rb +32 -4
  103. data/lib/capybara/spec/session/has_selector_spec.rb +4 -4
  104. data/lib/capybara/spec/session/has_text_spec.rb +5 -12
  105. data/lib/capybara/spec/session/html_spec.rb +1 -1
  106. data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
  107. data/lib/capybara/spec/session/node_spec.rb +169 -33
  108. data/lib/capybara/spec/session/refresh_spec.rb +2 -1
  109. data/lib/capybara/spec/session/save_page_spec.rb +4 -4
  110. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
  111. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
  112. data/lib/capybara/spec/session/window/window_spec.rb +8 -8
  113. data/lib/capybara/spec/session/window/windows_spec.rb +1 -1
  114. data/lib/capybara/spec/spec_helper.rb +13 -14
  115. data/lib/capybara/spec/test_app.rb +23 -21
  116. data/lib/capybara/spec/views/form.erb +36 -3
  117. data/lib/capybara/spec/views/with_animation.erb +8 -0
  118. data/lib/capybara/spec/views/with_dragula.erb +3 -1
  119. data/lib/capybara/spec/views/with_html.erb +2 -2
  120. data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
  121. data/lib/capybara/spec/views/with_js.erb +3 -0
  122. data/lib/capybara/spec/views/with_sortable_js.erb +1 -1
  123. data/lib/capybara/version.rb +1 -1
  124. data/lib/capybara/window.rb +3 -7
  125. data/spec/basic_node_spec.rb +9 -8
  126. data/spec/capybara_spec.rb +1 -1
  127. data/spec/dsl_spec.rb +14 -1
  128. data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
  129. data/spec/minitest_spec.rb +3 -2
  130. data/spec/rack_test_spec.rb +28 -6
  131. data/spec/regexp_dissassembler_spec.rb +0 -4
  132. data/spec/result_spec.rb +40 -29
  133. data/spec/rspec/features_spec.rb +3 -1
  134. data/spec/rspec/scenarios_spec.rb +4 -0
  135. data/spec/rspec/shared_spec_matchers.rb +63 -51
  136. data/spec/rspec_spec.rb +4 -0
  137. data/spec/selector_spec.rb +17 -2
  138. data/spec/selenium_spec_chrome.rb +45 -21
  139. data/spec/selenium_spec_chrome_remote.rb +7 -1
  140. data/spec/selenium_spec_firefox.rb +15 -13
  141. data/spec/server_spec.rb +60 -49
  142. data/spec/shared_selenium_node.rb +18 -0
  143. data/spec/shared_selenium_session.rb +98 -7
  144. data/spec/spec_helper.rb +1 -1
  145. metadata +50 -14
  146. data/lib/capybara/spec/session/source_spec.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a441a0ffad497da4d5342b4a84c165d0922f92a049aa7035db212f210a1175c
4
- data.tar.gz: c24b692401fc4eb28d73bdee5dc8f20b01d6cca582b0d94a4e015ac35485bc63
3
+ metadata.gz: 516861530f59d3d9713daba7379838146575b920f787ac2c3f5c4bbffc6bf44d
4
+ data.tar.gz: 85b3fb81bf05e43122c2eef320a7a2dbd500033723ebbc04ebc414b0a42d0881
5
5
  SHA512:
6
- metadata.gz: 3003c43d66f8cf415de12e9c9db95c5a60022aa10d63c3372074763049c7719041162eee9bb99fec17a7bf4190d252812b5d1513df3f22a586501f9f671dbea1
7
- data.tar.gz: de605e659b3c0e78065acd429e3d40c1e7758840b8cb8dd417229d440581b8363535d00a4193c51a2561a2ccde8b57b832d8176a8fb3b932a46e6682d161ddbd
6
+ metadata.gz: 7f745dac92b73afa56f43a2a509052c7fc5d1efa458863b0b3f05507c664847d6f67720a2c2a680e21126888e63a6eaf6a0e9be7d1a4df9d6aaa9ec61d832e29
7
+ data.tar.gz: 53532156dd31631879a0a8fda93126f259a5cd856a6cec82e6283f9f96e1cc2d98b788e4414ffee5756024d14819450d358529aa90d4c948618e82b878342ebd
data/History.md CHANGED
@@ -1,3 +1,143 @@
1
+ # Version 3.35.3
2
+ Release date: 2021-01-29
3
+
4
+ ### Fixed
5
+ * Just a release to have the correct dates in the History.md in released gem
6
+
7
+ # Version 3.35.2
8
+ Release date: 2021-01-29
9
+
10
+ ### Fixed
11
+
12
+ * Selenium deprecation suppressor with Selenium 3.x
13
+
14
+ # Version 3.35.1
15
+ Release date: 2021-01-26
16
+
17
+ ### Fixed
18
+
19
+ * Default chrome driver registrations use chrome - Issue #2442 [Yuriy Alekseyev]
20
+ * 'Capybara.test_id' usage with the :button selector - Issue #2443
21
+
22
+ # Version 3.35.0
23
+ Release date: 2021-01-25
24
+
25
+ ### Added
26
+
27
+ * Support Regexp matching for individual class names in :class filter passed an Array
28
+ * Animation disabler now supports JQuery animation disabling when JQuery loaded from body [Chien-Wei Huang]
29
+
30
+ ### Fixed
31
+
32
+ * :button selector type use with `enable_aria_role` [Sean Doyle]
33
+ * <label> elements don't associate with aria-role buttons
34
+ * Ignore Selenium::WebDriver::Error::InvalidSessionIdError when quitting driver [Robin Daugherty]
35
+ * Firefox: Don't click input when sending keys if already focused
36
+ * Miscellaneous issues with selenium-webdriver 4.0.0.alphas
37
+ * Nil return error in node details optimizations
38
+ * Animation disabler now inserts XHTML compliant content [Dale Morgan]
39
+
40
+ # Version 3.34.0
41
+ Release date: 2020-11-26
42
+
43
+ ### Added
44
+
45
+ * Ability to fill in with emoji when using Chrome with selenium driver (Firefox already worked)
46
+ * Current path assertions/expectations accept optional filter block
47
+ * Animation disabler now specifies `scroll-behavior: auto;` [Nathan Broadbent]
48
+ * :button selector can now find elements by label text [Sean Doyle]
49
+ * `Session#send_keys` to send keys to the current element with focus in drivers that support the
50
+ concept of a current element [Sean Doyle]
51
+
52
+ ### Changed
53
+
54
+ * Text query validates the type parameter to prevent undefined behavior
55
+
56
+ ### Fixed
57
+
58
+ * racktest driver better handles fragments and redirection to urls that include fragments
59
+ * Don't error when attempting to get XPath location of a shadow element
60
+ * Missing `readonly?` added to Node::Simple
61
+ * Selenium version detection when loaded via alternate method [Joel Hawksley]
62
+ * Connection count issue if REQUEST_URI value changed by app [Blake Williams]
63
+ * Maintain URI fragment when redirecting in rack-test driver
64
+ * Text query error message [Wojciech Wnętrzak]
65
+ * Checking a checkbox/radio button with `allow_label_click` now works if there are multiple labels (Issue #2421)
66
+ * `drop` with `Pathname` (Issue #2424)[Máximo Mussini]
67
+
68
+ # Version 3.33.0
69
+ Release date: 2020-06-21
70
+
71
+ ### Added
72
+
73
+ * Block passed to `within_session` now receives the new and old session
74
+ * Support for aria-role button when enabled [Seiei Miyagi]
75
+ * Support for aria-role link when enabled
76
+ * Support for `validation_message` filter with :field and :fillable_field selectors
77
+ * Deprecation warnings show source location [Koichi ITO]
78
+
79
+ ### Changed
80
+
81
+ * Ruby 2.5.0+ is now required
82
+ * Deprecated direct manipulation of the driver and server registries
83
+
84
+ ### Fixed
85
+
86
+ * Ruby 2.7 warning in minitest `assert_text` [Eileen M. Uchitelle]
87
+
88
+
89
+ # Version 3.32.2
90
+ Release date: 2020-05-16
91
+
92
+ ### Fixed
93
+
94
+ * Don't use lazy enumerator with JRuby due to leaking threads
95
+ * Ruby 2.7 deprecation warning when registering Webrick [Jon Zeppieri]
96
+ * `have_text` description [Juan Pablo Rinaldi]
97
+
98
+ # Version 3.32.1
99
+ Release date: 2020-04-05
100
+
101
+ ### Fixed
102
+
103
+ * Rapid set now respects field maxlength (Issue #2332)
104
+ * Only patch pause into legacy actions in Selenium < 4 (Issue #2334)
105
+
106
+ # Version 3.32.0
107
+ Release date: 2020-03-29
108
+
109
+ ### Added
110
+
111
+ * Support `delay` setting on click with Selenium
112
+ * Implement rapid set for values longer than 30 characters in text fields with Selenium
113
+
114
+ ### Fixed
115
+
116
+ * Result#[] and negative max on ranges (Issue #2302/2303) [Jeremy Evans]
117
+ * RackTest form submission rewrites query string when using GET method
118
+ * Ruby 2.7 deprecation warnings in RSpec matcher proxies
119
+
120
+ # Version 3.31.0
121
+ Release date: 2020-01-26
122
+
123
+ ### Added
124
+
125
+ * Support setting range inputs with the selenium driver [Andrew White]
126
+ * Support setting range inputs with the rack driver
127
+ * Support drop modifier keys in drag & drop [Elliot Crosby-McCullough]
128
+ * `enabled_options` and `disabled options` filters for select selector
129
+ * Support beginless ranges
130
+ * Optionally allow `all` results to be reloaded when stable - Beta feature - may be removed in
131
+ future version if problems occur
132
+
133
+ ### Fixed
134
+
135
+ * Fix Ruby 2.7 deprecation notices around keyword arguments. I have tried to do this without
136
+ any breaking changes, but due to the nature of the 2.7 changes and some selector types accepting
137
+ Hashes as locators there are a lot of edge cases. If you find any broken cases please report
138
+ them and I'll see if they're fixable.
139
+ * Clicking on details/summary element behavior in rack_test driver_
140
+
1
141
  # Version 3.30.0
2
142
  Release date: 2019-12-24
3
143
 
@@ -90,8 +230,8 @@ Release date: 2019-06-27
90
230
 
91
231
  ### Fixed
92
232
 
93
- * Woraround issue with chromedriver 76/77 in W3C mode losing mouse state during legacy drag. Only fixed if
94
- both source and target are simultaenously inside the viewport - Issue #2223
233
+ * Work around issue with chromedriver 76/77 in W3C mode losing mouse state during legacy drag. Only fixed if
234
+ both source and target are simultaneously inside the viewport - Issue #2223
95
235
  * Negative ancestor expectations/predicates were incorrectly checking siblings rather than ancestors
96
236
 
97
237
  # Version 3.24.0
@@ -370,7 +510,7 @@ Release date: 2018-10-23
370
510
 
371
511
  ### Fixed
372
512
 
373
- * Selector `css` expression definiton declared filters now work again
513
+ * Selector `css` expression definition declared filters now work again
374
514
  * Cleaned up warnings [Yuji Yaginuma]
375
515
  * Workaround installation of rspec matcher proxies under jruby by reverting to the old solution not using prepend, so jruby bugs are not hit - Issue #2115
376
516
 
@@ -487,7 +627,7 @@ Release date: 2018-07-19
487
627
 
488
628
  ### Fixed
489
629
 
490
- * Make selenium driver :backspace clear stategy work even if caret location is in middle of field content [Champier Cyril]
630
+ * Make selenium driver :backspace clear strategy work even if caret location is in middle of field content [Champier Cyril]
491
631
  * Selenium issue with fieldset nested in disabled fieldset not being considered disabled
492
632
  * `Session#evaluate_script` and `Element#evaluate_script` now strip leading/trailing whitespace from scripts [Ian Lesperance]
493
633
 
@@ -586,7 +726,7 @@ Release date: 2018-04-13
586
726
  ### Fixes
587
727
 
588
728
  * Fix expression filter descriptions in some selector failure messages
589
- * Fix compounding of negated matechers - Issue #2010
729
+ * Fix compounding of negated matchers - Issue #2010
590
730
 
591
731
  # Version 3.0.1
592
732
  Release date: 2018-04-06
@@ -860,7 +1000,7 @@ Release date: 2016-12-05
860
1000
  * Options for clearing session/local storage on reset added to the Selenium driver
861
1001
  * Window size changes wait for the size to stabilize
862
1002
  * Defined return value for most actions
863
- * Ignore specific error when qutting selenium driver instance - Issue #1773 [Dylan Reichstadt, Thomas Walpole]
1003
+ * Ignore specific error when quitting selenium driver instance - Issue #1773 [Dylan Reichstadt, Thomas Walpole]
864
1004
  * Warn on selenium unknown errors rather than raising when quitting driver [Adam Pohorecki, Thomas Walpole]
865
1005
  * Capybara::Result#each now returns an `Enumerator` when called without a block - Issue #1777 [Thomas Walpole]
866
1006
 
@@ -922,7 +1062,7 @@ Release date: 2016-09-19
922
1062
 
923
1063
  ### Fixed
924
1064
 
925
- * Issue with rack-test driver and obselete mime-types when using `#attach_file` - Issue #1756 [Thomas Walpole]
1065
+ * Issue with rack-test driver and obsolete mime-types when using `#attach_file` - Issue #1756 [Thomas Walpole]
926
1066
 
927
1067
  ### Added
928
1068
 
@@ -989,7 +1129,7 @@ Release date: 2016-04-07
989
1129
 
990
1130
  ### Added
991
1131
 
992
- * Capybara now waits for requests to Capybaras server to complete while restting the session [John Hawthorn, Thomas Walpole]
1132
+ * Capybara now waits for requests to Capybaras server to complete while resetting the session [John Hawthorn, Thomas Walpole]
993
1133
  * Capybara.reuse_server option to allow disabling of sharing server instance between sessions [Thomas Walpole]
994
1134
  * :multiple filter added to relevant selectors [Thomas Walpole]
995
1135
  * Provided server registrations for :webrick and :puma. Capybara.server = :puma for testing with Rails 5 [Thomas Walpole]
@@ -1003,7 +1143,7 @@ Release date: 2016-04-07
1003
1143
 
1004
1144
  # Version 2.6.2
1005
1145
 
1006
- Relase date: 2016-01-27
1146
+ Release date: 2016-01-27
1007
1147
 
1008
1148
  ### Fixed
1009
1149
 
@@ -1549,8 +1689,8 @@ Release date: 2011-06-14
1549
1689
  * Rack::Test driver honours maxlength on input fields [Guilherme Carvalho]
1550
1690
  * Rack::Test now works as expected with domains and subdomains [Jonas Nicklas]
1551
1691
  * Session is reset more thoroughly between tests. [Jonas Nicklas]
1552
- * Raise error when uploading non-existant file [Jonas Nicklas]
1553
- * Rack reponse body should respond to #each [Piotr Sarnacki]
1692
+ * Raise error when uploading non-existent file [Jonas Nicklas]
1693
+ * Rack response body should respond to #each [Piotr Sarnacki]
1554
1694
  * Deprecation warnings with selenium webdriver 0.2.0 [Aaron Gibraltar]
1555
1695
  * Selenium Chrome no longer YELLS tagname [Carl Jackson & David W. Frank]
1556
1696
  * Capybara no longer strips encoding before sending to Rack [Jonas Nicklas]
@@ -1692,7 +1832,7 @@ Release date: 2010-05-12
1692
1832
 
1693
1833
  Release date: 2010-04-09
1694
1834
 
1695
- This is a drop in compatible maintainance release. It's mostly
1835
+ This is a drop in compatible maintenance release. It's mostly
1696
1836
  important for driver authors.
1697
1837
 
1698
1838
  ### Added
@@ -1711,7 +1851,7 @@ important for driver authors.
1711
1851
 
1712
1852
  Release date: 2010-03-22
1713
1853
 
1714
- This is a maintainance release with minor bug fixes, should be
1854
+ This is a maintenance release with minor bug fixes, should be
1715
1855
  drop in compatible.
1716
1856
 
1717
1857
  ### Added
data/README.md CHANGED
@@ -7,8 +7,6 @@
7
7
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
8
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=capybara&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=capybara&package-manager=bundler&version-scheme=semver)
9
9
 
10
- **Note** You are viewing the README for the 3.30.x Capybara release.
11
-
12
10
  Capybara helps you test web applications by simulating how a real user would
13
11
  interact with your app. It is agnostic about the driver running your tests and
14
12
  comes with Rack::Test and Selenium support built in. WebKit is supported
@@ -76,7 +74,7 @@ GitHub): http://groups.google.com/group/ruby-capybara
76
74
 
77
75
  ## <a name="setup"></a>Setup
78
76
 
79
- Capybara requires Ruby 2.4.0 or later. To install, add this line to your
77
+ Capybara requires Ruby 2.5.0 or later. To install, add this line to your
80
78
  `Gemfile` and run `bundle install`:
81
79
 
82
80
  ```ruby
@@ -149,7 +147,7 @@ require 'capybara/rspec'
149
147
 
150
148
  If you are using Rails, put your Capybara specs in `spec/features` or `spec/system` (only works
151
149
  if [you have it configured in
152
- RSpec](https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#file-type-inference-disabled))
150
+ RSpec](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/directory-structure))
153
151
  and if you have your Capybara specs in a different directory, then tag the
154
152
  example groups with `type: :feature` or `type: :system` depending on which type of test you're writing.
155
153
 
@@ -1055,6 +1053,13 @@ additional info about how the underlying driver can be configured.
1055
1053
  are testing for specific server errors and using multiple sessions make sure to test for the
1056
1054
  errors using the initial session (usually :default)
1057
1055
 
1056
+ * If WebMock is enabled, you may encounter a "Too many open files"
1057
+ error. A simple `page.find` call may cause thousands of HTTP requests
1058
+ until the timeout occurs. By default, WebMock will cause each of these
1059
+ requests to spawn a new connection. To work around this problem, you
1060
+ may need to [enable WebMock's `net_http_connect_on_start: true`
1061
+ parameter](https://github.com/bblimke/webmock/blob/master/README.md#connecting-on-nethttpstart).
1062
+
1058
1063
  ## <a name="threadsafe"></a>"Threadsafe" mode
1059
1064
 
1060
1065
  In normal mode most of Capybara's configuration options are global settings which can cause issues
data/lib/capybara.rb CHANGED
@@ -5,6 +5,7 @@ require 'nokogiri'
5
5
  require 'xpath'
6
6
  require 'forwardable'
7
7
  require 'capybara/config'
8
+ require 'capybara/registration_container'
8
9
 
9
10
  module Capybara
10
11
  class CapybaraError < StandardError; end
@@ -81,6 +82,7 @@ module Capybara
81
82
  # - **default_selector** (`:css`, `:xpath` = `:css`) - Methods which take a selector use the given type by default. See also {Capybara::Selector}.
82
83
  # - **default_set_options** (Hash = `{}`) - The default options passed to {Capybara::Node::Element#set Element#set}.
83
84
  # - **enable_aria_label** (Boolean = `false`) - Whether fields, links, and buttons will match against `aria-label` attribute.
85
+ # - **enable_aria_role** (Boolean = `false`) - Selectors will check for relevant aria role (currently only `button`).
84
86
  # - **exact** (Boolean = `false`) - Whether locators are matched exactly or with substrings. Only affects selector conditions
85
87
  # written using the `XPath#is` method.
86
88
  # - **exact_text** (Boolean = `false`) - Whether the text matchers and `:text` filter match exactly or on substrings.
@@ -93,6 +95,7 @@ module Capybara
93
95
  # - **save_path** (String = `Dir.pwd`) - Where to put pages saved through {Capybara::Session#save_page save_page}, {Capybara::Session#save_screenshot save_screenshot},
94
96
  # {Capybara::Session#save_and_open_page save_and_open_page}, or {Capybara::Session#save_and_open_screenshot save_and_open_screenshot}.
95
97
  # - **server** (Symbol = `:default` (which uses puma)) - The name of the registered server to use when running the app under test.
98
+ # - **server_port** (Integer) - The port Capybara will run the application server on, if not specified a random port will be used.
96
99
  # - **server_errors** (Array\<Class> = `[Exception]`) - Error classes that should be raised in the tests if they are raised in the server
97
100
  # and {configure raise_server_errors} is `true`.
98
101
  # - **test_id** (Symbol, String, `nil` = `nil`) - Optional attribute to match locator against with built-in selectors along with id.
@@ -124,7 +127,7 @@ module Capybara
124
127
  # @yieldreturn [Capybara::Driver::Base] A Capybara driver instance
125
128
  #
126
129
  def register_driver(name, &block)
127
- drivers[name] = block
130
+ drivers.send(:register, name, block)
128
131
  end
129
132
 
130
133
  ##
@@ -143,7 +146,7 @@ module Capybara
143
146
  # @yieldparam host The host/ip to bind to
144
147
  #
145
148
  def register_server(name, &block)
146
- servers[name.to_sym] = block
149
+ servers.send(:register, name.to_sym, block)
147
150
  end
148
151
 
149
152
  ##
@@ -197,11 +200,11 @@ module Capybara
197
200
  end
198
201
 
199
202
  def drivers
200
- @drivers ||= {}
203
+ @drivers ||= RegistrationContainer.new
201
204
  end
202
205
 
203
206
  def servers
204
- @servers ||= {}
207
+ @servers ||= RegistrationContainer.new
205
208
  end
206
209
 
207
210
  # Wraps the given string, which should contain an HTML document or fragment
@@ -349,7 +352,8 @@ module Capybara
349
352
  #
350
353
  # Yield a block using a specific session name or {Capybara::Session} instance.
351
354
  #
352
- def using_session(name_or_session)
355
+ def using_session(name_or_session, &block)
356
+ previous_session = current_session
353
357
  previous_session_info = {
354
358
  specified_session: specified_session,
355
359
  session_name: session_name,
@@ -362,7 +366,12 @@ module Capybara
362
366
  else
363
367
  self.session_name = name_or_session
364
368
  end
365
- yield
369
+
370
+ if block.arity.zero?
371
+ yield
372
+ else
373
+ yield current_session, previous_session
374
+ end
366
375
  ensure
367
376
  self.session_name, self.specified_session = previous_session_info.values_at(:session_name, :specified_session)
368
377
  self.current_driver, self.app = previous_session_info.values_at(:current_driver, :app) if threadsafe
@@ -394,7 +403,7 @@ module Capybara
394
403
  template.inner_html = ''
395
404
  end
396
405
  document.xpath('//textarea').each do |textarea|
397
- textarea['_capybara_raw_value'] = textarea.content.sub(/\A\n/, '')
406
+ textarea['_capybara_raw_value'] = textarea.content.delete_prefix("\n")
398
407
  end
399
408
  end
400
409
  end
@@ -475,7 +484,7 @@ module Capybara
475
484
  require 'capybara/rack_test/node'
476
485
  require 'capybara/rack_test/form'
477
486
  require 'capybara/rack_test/browser'
478
- require 'capybara/rack_test/css_handlers.rb'
487
+ require 'capybara/rack_test/css_handlers'
479
488
 
480
489
  require 'capybara/selenium/node'
481
490
  require 'capybara/selenium/driver'
@@ -501,6 +510,7 @@ Capybara.configure do |config|
501
510
  config.visible_text_only = false
502
511
  config.automatic_label_click = false
503
512
  config.enable_aria_label = false
513
+ config.enable_aria_role = false
504
514
  config.reuse_server = true
505
515
  config.default_set_options = {}
506
516
  config.test_id = nil
@@ -9,11 +9,9 @@ module Capybara
9
9
 
10
10
  OPTIONS = %i[app reuse_server threadsafe server default_driver javascript_driver allow_gumbo].freeze
11
11
 
12
- attr_accessor :app
13
- attr_reader :reuse_server, :threadsafe
14
- attr_reader :session_options
12
+ attr_accessor :app, :allow_gumbo
13
+ attr_reader :reuse_server, :threadsafe, :session_options
15
14
  attr_writer :default_driver, :javascript_driver
16
- attr_accessor :allow_gumbo
17
15
 
18
16
  SessionConfig::OPTIONS.each do |method|
19
17
  def_delegators :session_options, method, "#{method}="
@@ -83,10 +81,10 @@ module Capybara
83
81
  @javascript_driver || :selenium
84
82
  end
85
83
 
86
- def deprecate(method, alternate_method, once = false)
84
+ def deprecate(method, alternate_method, once: false)
87
85
  @deprecation_notified ||= {}
88
86
  unless once && @deprecation_notified[method]
89
- warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead"
87
+ Capybara::Helpers.warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead: #{Capybara::Helpers.filter_backtrace(caller)}"
90
88
  end
91
89
  @deprecation_notified[method] = true
92
90
  end
@@ -22,6 +22,6 @@ end
22
22
  Before do |scenario|
23
23
  scenario.source_tag_names.each do |tag|
24
24
  driver_name = tag.sub(/^@/, '').to_sym
25
- Capybara.current_driver = driver_name if Capybara.drivers.key?(driver_name)
25
+ Capybara.current_driver = driver_name if Capybara.drivers[driver_name]
26
26
  end
27
27
  end
@@ -59,6 +59,10 @@ class Capybara::Driver::Base
59
59
  raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#status_code'
60
60
  end
61
61
 
62
+ def send_keys(*)
63
+ raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#send_keys'
64
+ end
65
+
62
66
  ##
63
67
  #
64
68
  # @param frame [Capybara::Node::Element, :parent, :top] The iframe element to switch to
data/lib/capybara/dsl.rb CHANGED
@@ -47,8 +47,16 @@ module Capybara
47
47
  end
48
48
 
49
49
  Session::DSL_METHODS.each do |method|
50
- define_method method do |*args, &block|
51
- page.send method, *args, &block
50
+ if RUBY_VERSION >= '2.7'
51
+ class_eval <<~METHOD, __FILE__, __LINE__ + 1
52
+ def #{method}(...)
53
+ page.method("#{method}").call(...)
54
+ end
55
+ METHOD
56
+ else
57
+ define_method method do |*args, &block|
58
+ page.send method, *args, &block
59
+ end
52
60
  end
53
61
  end
54
62
  end