capybara 3.32.2 → 3.39.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +227 -19
  3. data/README.md +36 -15
  4. data/lib/capybara/config.rb +18 -8
  5. data/lib/capybara/cucumber.rb +1 -1
  6. data/lib/capybara/driver/base.rb +8 -0
  7. data/lib/capybara/driver/node.rb +5 -1
  8. data/lib/capybara/dsl.rb +4 -10
  9. data/lib/capybara/helpers.rb +21 -2
  10. data/lib/capybara/minitest/spec.rb +14 -11
  11. data/lib/capybara/minitest.rb +2 -3
  12. data/lib/capybara/node/actions.rb +27 -27
  13. data/lib/capybara/node/base.rb +8 -7
  14. data/lib/capybara/node/document.rb +2 -2
  15. data/lib/capybara/node/element.rb +14 -7
  16. data/lib/capybara/node/finders.rb +18 -8
  17. data/lib/capybara/node/matchers.rb +12 -12
  18. data/lib/capybara/node/simple.rb +10 -2
  19. data/lib/capybara/node/whitespace_normalizer.rb +81 -0
  20. data/lib/capybara/queries/active_element_query.rb +18 -0
  21. data/lib/capybara/queries/ancestor_query.rb +3 -2
  22. data/lib/capybara/queries/base_query.rb +2 -2
  23. data/lib/capybara/queries/current_path_query.rb +14 -4
  24. data/lib/capybara/queries/selector_query.rb +78 -28
  25. data/lib/capybara/queries/sibling_query.rb +3 -2
  26. data/lib/capybara/queries/style_query.rb +1 -1
  27. data/lib/capybara/queries/text_query.rb +8 -2
  28. data/lib/capybara/rack_test/browser.rb +70 -11
  29. data/lib/capybara/rack_test/driver.rb +5 -4
  30. data/lib/capybara/rack_test/form.rb +30 -8
  31. data/lib/capybara/rack_test/node.rb +28 -22
  32. data/lib/capybara/registration_container.rb +41 -0
  33. data/lib/capybara/registrations/drivers.rb +20 -14
  34. data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
  35. data/lib/capybara/registrations/servers.rb +32 -11
  36. data/lib/capybara/result.rb +6 -10
  37. data/lib/capybara/rspec/matcher_proxies.rb +7 -7
  38. data/lib/capybara/rspec/matchers/base.rb +8 -6
  39. data/lib/capybara/rspec/matchers/compound.rb +1 -1
  40. data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
  41. data/lib/capybara/rspec/matchers/have_selector.rb +5 -5
  42. data/lib/capybara/rspec/matchers/match_style.rb +5 -0
  43. data/lib/capybara/rspec/matchers.rb +21 -20
  44. data/lib/capybara/rspec.rb +2 -0
  45. data/lib/capybara/selector/builders/css_builder.rb +2 -2
  46. data/lib/capybara/selector/builders/xpath_builder.rb +4 -2
  47. data/lib/capybara/selector/css.rb +1 -1
  48. data/lib/capybara/selector/definition/button.rb +29 -12
  49. data/lib/capybara/selector/definition/checkbox.rb +1 -1
  50. data/lib/capybara/selector/definition/css.rb +1 -1
  51. data/lib/capybara/selector/definition/datalist_input.rb +1 -1
  52. data/lib/capybara/selector/definition/element.rb +2 -1
  53. data/lib/capybara/selector/definition/file_field.rb +1 -1
  54. data/lib/capybara/selector/definition/fillable_field.rb +2 -2
  55. data/lib/capybara/selector/definition/label.rb +1 -1
  56. data/lib/capybara/selector/definition/link.rb +10 -1
  57. data/lib/capybara/selector/definition/radio_button.rb +1 -1
  58. data/lib/capybara/selector/definition/select.rb +1 -1
  59. data/lib/capybara/selector/definition/table.rb +1 -1
  60. data/lib/capybara/selector/definition/table_row.rb +2 -2
  61. data/lib/capybara/selector/definition.rb +14 -10
  62. data/lib/capybara/selector/filter_set.rb +6 -9
  63. data/lib/capybara/selector/regexp_disassembler.rb +2 -5
  64. data/lib/capybara/selector/selector.rb +14 -2
  65. data/lib/capybara/selector.rb +13 -3
  66. data/lib/capybara/selenium/atoms/src/isDisplayed.js +1 -1
  67. data/lib/capybara/selenium/driver.rb +71 -10
  68. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +10 -12
  69. data/lib/capybara/selenium/driver_specializations/edge_driver.rb +18 -16
  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 +5 -4
  73. data/lib/capybara/selenium/extensions/scroll.rb +8 -10
  74. data/lib/capybara/selenium/logger_suppressor.rb +13 -3
  75. data/lib/capybara/selenium/node.rb +90 -37
  76. data/lib/capybara/selenium/nodes/chrome_node.rb +29 -7
  77. data/lib/capybara/selenium/nodes/edge_node.rb +25 -3
  78. data/lib/capybara/selenium/nodes/firefox_node.rb +10 -5
  79. data/lib/capybara/selenium/nodes/safari_node.rb +5 -5
  80. data/lib/capybara/selenium/patches/action_pauser.rb +3 -3
  81. data/lib/capybara/selenium/patches/atoms.rb +5 -5
  82. data/lib/capybara/selenium/patches/logs.rb +7 -9
  83. data/lib/capybara/selenium/patches/pause_duration_fix.rb +1 -1
  84. data/lib/capybara/server/animation_disabler.rb +43 -21
  85. data/lib/capybara/server/middleware.rb +5 -3
  86. data/lib/capybara/session/config.rb +6 -2
  87. data/lib/capybara/session/matchers.rb +11 -11
  88. data/lib/capybara/session.rb +52 -44
  89. data/lib/capybara/spec/public/test.js +17 -1
  90. data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
  91. data/lib/capybara/spec/session/active_element_spec.rb +31 -0
  92. data/lib/capybara/spec/session/all_spec.rb +10 -14
  93. data/lib/capybara/spec/session/assert_text_spec.rb +17 -17
  94. data/lib/capybara/spec/session/attach_file_spec.rb +6 -0
  95. data/lib/capybara/spec/session/check_spec.rb +16 -0
  96. data/lib/capybara/spec/session/choose_spec.rb +6 -0
  97. data/lib/capybara/spec/session/click_button_spec.rb +11 -0
  98. data/lib/capybara/spec/session/click_link_or_button_spec.rb +9 -0
  99. data/lib/capybara/spec/session/click_link_spec.rb +11 -0
  100. data/lib/capybara/spec/session/current_scope_spec.rb +1 -1
  101. data/lib/capybara/spec/session/current_url_spec.rb +11 -1
  102. data/lib/capybara/spec/session/fill_in_spec.rb +6 -0
  103. data/lib/capybara/spec/session/find_link_spec.rb +10 -0
  104. data/lib/capybara/spec/session/find_spec.rb +7 -1
  105. data/lib/capybara/spec/session/first_spec.rb +1 -1
  106. data/lib/capybara/spec/session/frame/within_frame_spec.rb +2 -0
  107. data/lib/capybara/spec/session/has_all_selectors_spec.rb +5 -5
  108. data/lib/capybara/spec/session/has_ancestor_spec.rb +2 -2
  109. data/lib/capybara/spec/session/has_any_selectors_spec.rb +6 -2
  110. data/lib/capybara/spec/session/has_button_spec.rb +81 -0
  111. data/lib/capybara/spec/session/has_css_spec.rb +2 -1
  112. data/lib/capybara/spec/session/has_current_path_spec.rb +18 -5
  113. data/lib/capybara/spec/session/has_field_spec.rb +41 -1
  114. data/lib/capybara/spec/session/has_link_spec.rb +40 -0
  115. data/lib/capybara/spec/session/has_none_selectors_spec.rb +7 -7
  116. data/lib/capybara/spec/session/has_select_spec.rb +14 -8
  117. data/lib/capybara/spec/session/has_selector_spec.rb +19 -4
  118. data/lib/capybara/spec/session/has_text_spec.rb +6 -25
  119. data/lib/capybara/spec/session/html_spec.rb +1 -1
  120. data/lib/capybara/spec/session/matches_style_spec.rb +4 -2
  121. data/lib/capybara/spec/session/node_spec.rb +111 -10
  122. data/lib/capybara/spec/session/refresh_spec.rb +2 -1
  123. data/lib/capybara/spec/session/reset_session_spec.rb +13 -0
  124. data/lib/capybara/spec/session/save_page_spec.rb +4 -4
  125. data/lib/capybara/spec/session/scroll_spec.rb +7 -5
  126. data/lib/capybara/spec/session/visit_spec.rb +20 -0
  127. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
  128. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
  129. data/lib/capybara/spec/session/window/window_spec.rb +2 -2
  130. data/lib/capybara/spec/session/window/windows_spec.rb +2 -2
  131. data/lib/capybara/spec/session/within_spec.rb +13 -0
  132. data/lib/capybara/spec/spec_helper.rb +23 -16
  133. data/lib/capybara/spec/test_app.rb +113 -34
  134. data/lib/capybara/spec/views/animated.erb +1 -1
  135. data/lib/capybara/spec/views/form.erb +53 -5
  136. data/lib/capybara/spec/views/frame_child.erb +1 -1
  137. data/lib/capybara/spec/views/frame_one.erb +1 -1
  138. data/lib/capybara/spec/views/frame_parent.erb +1 -1
  139. data/lib/capybara/spec/views/frame_two.erb +1 -1
  140. data/lib/capybara/spec/views/initial_alert.erb +2 -1
  141. data/lib/capybara/spec/views/layout.erb +10 -0
  142. data/lib/capybara/spec/views/obscured.erb +1 -1
  143. data/lib/capybara/spec/views/offset.erb +2 -1
  144. data/lib/capybara/spec/views/path.erb +2 -2
  145. data/lib/capybara/spec/views/popup_one.erb +1 -1
  146. data/lib/capybara/spec/views/popup_two.erb +1 -1
  147. data/lib/capybara/spec/views/react.erb +2 -2
  148. data/lib/capybara/spec/views/scroll.erb +2 -1
  149. data/lib/capybara/spec/views/spatial.erb +1 -1
  150. data/lib/capybara/spec/views/with_animation.erb +10 -3
  151. data/lib/capybara/spec/views/with_base_tag.erb +2 -2
  152. data/lib/capybara/spec/views/with_dragula.erb +5 -3
  153. data/lib/capybara/spec/views/with_fixed_header_footer.erb +2 -1
  154. data/lib/capybara/spec/views/with_hover.erb +2 -2
  155. data/lib/capybara/spec/views/with_html.erb +3 -3
  156. data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
  157. data/lib/capybara/spec/views/with_js.erb +5 -3
  158. data/lib/capybara/spec/views/with_jstree.erb +1 -1
  159. data/lib/capybara/spec/views/with_namespace.erb +1 -0
  160. data/lib/capybara/spec/views/with_scope.erb +2 -2
  161. data/lib/capybara/spec/views/with_shadow.erb +31 -0
  162. data/lib/capybara/spec/views/with_slow_unload.erb +2 -1
  163. data/lib/capybara/spec/views/with_sortable_js.erb +3 -3
  164. data/lib/capybara/spec/views/with_unload_alert.erb +1 -0
  165. data/lib/capybara/spec/views/with_windows.erb +1 -1
  166. data/lib/capybara/spec/views/within_frames.erb +1 -1
  167. data/lib/capybara/version.rb +1 -1
  168. data/lib/capybara/window.rb +4 -8
  169. data/lib/capybara.rb +40 -31
  170. data/spec/basic_node_spec.rb +25 -11
  171. data/spec/capybara_spec.rb +13 -1
  172. data/spec/counter_spec.rb +35 -0
  173. data/spec/css_builder_spec.rb +1 -1
  174. data/spec/css_splitter_spec.rb +1 -1
  175. data/spec/dsl_spec.rb +18 -3
  176. data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
  177. data/spec/fixtures/selenium_driver_rspec_success.rb +3 -3
  178. data/spec/minitest_spec.rb +7 -2
  179. data/spec/minitest_spec_spec.rb +4 -0
  180. data/spec/per_session_config_spec.rb +1 -1
  181. data/spec/rack_test_spec.rb +41 -12
  182. data/spec/result_spec.rb +32 -35
  183. data/spec/rspec/features_spec.rb +6 -4
  184. data/spec/rspec/scenarios_spec.rb +6 -2
  185. data/spec/rspec/shared_spec_matchers.rb +64 -52
  186. data/spec/rspec_matchers_spec.rb +25 -0
  187. data/spec/rspec_spec.rb +6 -2
  188. data/spec/sauce_spec_chrome.rb +4 -4
  189. data/spec/selector_spec.rb +21 -6
  190. data/spec/selenium_spec_chrome.rb +50 -31
  191. data/spec/selenium_spec_chrome_remote.rb +16 -11
  192. data/spec/selenium_spec_edge.rb +12 -6
  193. data/spec/selenium_spec_firefox.rb +39 -20
  194. data/spec/selenium_spec_firefox_remote.rb +19 -4
  195. data/spec/selenium_spec_ie.rb +7 -8
  196. data/spec/selenium_spec_safari.rb +34 -20
  197. data/spec/server_spec.rb +65 -54
  198. data/spec/shared_selenium_node.rb +0 -4
  199. data/spec/shared_selenium_session.rb +104 -12
  200. data/spec/spec_helper.rb +36 -3
  201. data/spec/whitespace_normalizer_spec.rb +54 -0
  202. data/spec/xpath_builder_spec.rb +1 -1
  203. metadata +82 -21
  204. data/lib/capybara/spec/session/source_spec.rb +0 -0
  205. data/lib/capybara/spec/views/with_title.erb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 410e79ae955fb505f242247fae85f0b738307e685c2e62cc7a4fda936f5be86a
4
- data.tar.gz: d815d9d84f898e72aa08003e3370c673e169e08a794df6804459c18a65d7d367
3
+ metadata.gz: '0945d8fedaab75fa31a90d12105de7318d78c20a46955a1b78ae88dc791f6a5a'
4
+ data.tar.gz: 9a59ca68ff9d44ef28597603ed275ebef28c79c8b6fb76ffdc26daaee68ab383
5
5
  SHA512:
6
- metadata.gz: 60471fefa8d5bc99eddaa19afcd35ff8b382f7fbede21ffac5d402b89ca54d89b9252ebffde8eb0565d820d3d1d0136d943912dd9da18f9366e3b75660870e4e
7
- data.tar.gz: 3fb1b539d4a128e6e2ba3f7fcd5e9daff0f64c60691eef1a2c69c166668c3ad28fbd3bbd5414162e73f86fc51e608f18065075b0956f5ea923c572d32d585052
6
+ metadata.gz: dbb58a338e2408140ce5e6a44bc141fc44833952c10f611996f5a217c9a0ad00f8d6344a1c16b0bf53000801f9e1d45ef3848cb0fa886dabe68c6d766a42372a
7
+ data.tar.gz: db985c0c947ff348c80008fd4c90232a0ad4dcd38dbe8694b157ecfb512c099d6e9bc08177d8a115e1db17cca35c68903e10662da0fdd14c4f1a2ab671932b16
data/History.md CHANGED
@@ -1,10 +1,219 @@
1
+ # Version 3.39.2
2
+ Release date: 2023-06-10
3
+
4
+ ### Fixed
5
+
6
+ * Fix Selenium version comparison [aki77]
7
+
8
+ # Version 3.39.1
9
+ Release date: 2023-05-12
10
+
11
+ ### Fixed
12
+
13
+ * Fix usage of Selenium logger
14
+
15
+ # Version 3.39.0
16
+ Release date: 2023-04-02
17
+
18
+ ### Added
19
+
20
+ * Support `:target` filter option on `:link` selector [Yudai Takada]
21
+ * Experimental Rack 3 support
22
+ * Text normalization performance improvements [Brandon Weaver]
23
+
24
+ ### Fixed
25
+
26
+ * MS Edge button click [Brian J. Bayer]
27
+ * Options/Capabilities choosing based on Selenium versions
28
+ * Support for base versions [Matijs van Zuijlen]
29
+ * ExpectedError not defined in Selenium 4+
30
+ * Filter block forwarding to a number of matchers [Christophe Bliard]
31
+ ### Changed
32
+
33
+ * Dropped support for rack 1.x
34
+
35
+ # Version 3.38.0
36
+ Release date: 2022-11-03
37
+
38
+ ### Changed
39
+
40
+ * Capybara.w3c_click_offset now defaults to true. If you need click offsets to be from the elements top left corner set it to false in your config
41
+
42
+ ### Added
43
+
44
+ * Support Selenium 4.3 changes to click offset calculations
45
+ * `click`, `double_click`, `right_click` can now be called on the session to click the currently scoped element (or document)
46
+ * `Session#within` now passes the scoped element to the block
47
+ * Support rack-test 2+
48
+ * Retry interval is now configurable [Masahiro NOMOTO]
49
+ * Support Puma 6 - Issue #2590
50
+ * Selenium: DetachedShadowRootError is treated as an invalid element error [Perryn Fowler]
51
+ * Selenium: When inspected shadow roots will have a tag name of "ShadowRoot"
52
+ * `evaluate_async_script` added to Session::DSL_METHODS [Henry Blyth]
53
+
54
+ ### Fixed
55
+
56
+ * Use higher precision clock in Capybara::Helpers::Timer if available
57
+ * rack-test driver behavior with \r\n - Issue #2547 [Stefan Hoffmann]
58
+ * Updated for deprecation of positional parameters in Selenium::WebDriver::ActionBuilder#pause
59
+ * Explicitly set cause on server raised errors
60
+ * Options no longer duplicated in have_xxx invalid option error message [Yudai Takada]
61
+ * Animation disabler is now threadsafe [Daniel Sheppard]
62
+ * Server connection count tracking [Oleksandr K.]
63
+ * Ensure scopes are reset when session is [Henry Blyth]
64
+
65
+ # Version 3.37.1
66
+ Release date: 2022-05-09
67
+
68
+ ### Fixed
69
+
70
+ * Regression in rack-test visit - Issue #2548
71
+
72
+ # Version 3.37.0
73
+ Release date: 2022-05-07
74
+
75
+ ### Changed
76
+
77
+ * Ruby 2.7.0+ is now required
78
+
79
+ ### Added
80
+
81
+ * [Beta] CSP nonces inserted into animation disabler additions - Issue #2542
82
+ * Support `<base>` element in rack-test driver - ISsue #2544
83
+ * [Beta] `Element#shadow_root` support. Requires selenium-webdriver 4.1+. Only currently supported with Chrome when using the selenium driver. Note: only CSS can be used to find elements from the shadow root. Therefore you won't be able to use most Capybara helper methods (`fill_in`, `click_link`, `find_field`, etc) directly from the shadow root since those locators are built using XPath. If you first locate a descendant from the shadow root using CSS then you should be able to use all the Capybara methods from there.
84
+ * Regexp now supported for `exact_text` finder option
85
+
86
+ ### Fixed
87
+
88
+ * Fragments in referer headers in rack-test driver - Issue #2525
89
+ * Selenium v4.1 deprecation notice
90
+
91
+ # Version 3.36.0
92
+ Release date: 2021-10-24
93
+
94
+ ### Changed
95
+
96
+ * Ruby 2.6.0+ is now required
97
+ * Minimum selenium-webdriver supported is now 3.142.7
98
+
99
+ ### Added
100
+
101
+ * Support for selenium-webdriver 4.x
102
+ * `allow_label_click` accepts click options to be used when clicking an associated label
103
+ * Deprecated `allow_gumbo=` in favor of `use_html5_parsing=` to enable use of Nokogiri::HTML5 when available
104
+ * `Session#active_element` returns the element with focus - Not supported by the `RackTest` driver [Sean Doyle]
105
+ * Support `focused:` filter for finding interactive elements - Not supported by the `RackTest` driver [Sean Doyle]
106
+
107
+ ### Fixed
108
+
109
+ * Sibling and ancestor queries now work with Simple::Node - Issue #2452
110
+ * rack_test correctly ignores readonly attribute on specific input element types
111
+ * `Node#all_text` always returns a string - Issue #2477
112
+ * `have_any_of_selectors` negated match - Issue #2473
113
+ * `Document#scroll_to` fixed for standards behavior - pass quirks: true if you need the older behavior [Eric Anderson]
114
+ * Use capture on attach file event listener for better React compatibility [Jeff Way]
115
+ * Animation disabler produces valid HTML [Javi Martin]
116
+
117
+ ### Removed
118
+
119
+ * References to non-w3c mode in drivers/tests. Non-w3c mode is obsolete and no one should be using it anymore. Capybara hasn't been testing/supporting it in a while
120
+
121
+ # Version 3.35.3
122
+ Release date: 2021-01-29
123
+
124
+ ### Fixed
125
+
126
+ * Just a release to have the correct dates in the History.md in released gem
127
+
128
+ # Version 3.35.2
129
+ Release date: 2021-01-29
130
+
131
+ ### Fixed
132
+
133
+ * Selenium deprecation suppressor with Selenium 3.x
134
+
135
+ # Version 3.35.1
136
+ Release date: 2021-01-26
137
+
138
+ ### Fixed
139
+
140
+ * Default chrome driver registrations use chrome - Issue #2442 [Yuriy Alekseyev]
141
+ * 'Capybara.test_id' usage with the :button selector - Issue #2443
142
+
143
+ # Version 3.35.0
144
+ Release date: 2021-01-25
145
+
146
+ ### Added
147
+
148
+ * Support Regexp matching for individual class names in :class filter passed an Array
149
+ * Animation disabler now supports JQuery animation disabling when JQuery loaded from body [Chien-Wei Huang]
150
+
151
+ ### Fixed
152
+
153
+ * :button selector type use with `enable_aria_role` [Sean Doyle]
154
+ * <label> elements don't associate with aria-role buttons
155
+ * Ignore Selenium::WebDriver::Error::InvalidSessionIdError when quitting driver [Robin Daugherty]
156
+ * Firefox: Don't click input when sending keys if already focused
157
+ * Miscellaneous issues with selenium-webdriver 4.0.0.alphas
158
+ * Nil return error in node details optimizations
159
+ * Animation disabler now inserts XHTML compliant content [Dale Morgan]
160
+
161
+ # Version 3.34.0
162
+ Release date: 2020-11-26
163
+
164
+ ### Added
165
+
166
+ * Ability to fill in with emoji when using Chrome with selenium driver (Firefox already worked)
167
+ * Current path assertions/expectations accept optional filter block
168
+ * Animation disabler now specifies `scroll-behavior: auto;` [Nathan Broadbent]
169
+ * :button selector can now find elements by label text [Sean Doyle]
170
+ * `Session#send_keys` to send keys to the current element with focus in drivers that support the
171
+ concept of a current element [Sean Doyle]
172
+
173
+ ### Changed
174
+
175
+ * Text query validates the type parameter to prevent undefined behavior
176
+
177
+ ### Fixed
178
+
179
+ * racktest driver better handles fragments and redirection to urls that include fragments
180
+ * Don't error when attempting to get XPath location of a shadow element
181
+ * Missing `readonly?` added to Node::Simple
182
+ * Selenium version detection when loaded via alternate method [Joel Hawksley]
183
+ * Connection count issue if REQUEST_URI value changed by app [Blake Williams]
184
+ * Maintain URI fragment when redirecting in rack-test driver
185
+ * Text query error message [Wojciech Wnętrzak]
186
+ * Checking a checkbox/radio button with `allow_label_click` now works if there are multiple labels (Issue #2421)
187
+ * `drop` with `Pathname` (Issue #2424)[Máximo Mussini]
188
+
189
+ # Version 3.33.0
190
+ Release date: 2020-06-21
191
+
192
+ ### Added
193
+
194
+ * Block passed to `within_session` now receives the new and old session
195
+ * Support for aria-role button when enabled [Seiei Miyagi]
196
+ * Support for aria-role link when enabled
197
+ * Support for `validation_message` filter with :field and :fillable_field selectors
198
+ * Deprecation warnings show source location [Koichi ITO]
199
+
200
+ ### Changed
201
+
202
+ * Ruby 2.5.0+ is now required
203
+ * Deprecated direct manipulation of the driver and server registries
204
+
205
+ ### Fixed
206
+
207
+ * Ruby 2.7 warning in minitest `assert_text` [Eileen M. Uchitelle]
208
+
209
+
1
210
  # Version 3.32.2
2
211
  Release date: 2020-05-16
3
212
 
4
213
  ### Fixed
5
214
 
6
215
  * Don't use lazy enumerator with JRuby due to leaking threads
7
- * Ruby 2,7 deprecation warning when registering Webrick [Jon Zeppieri]
216
+ * Ruby 2.7 deprecation warning when registering Webrick [Jon Zeppieri]
8
217
  * `have_text` description [Juan Pablo Rinaldi]
9
218
 
10
219
  # Version 3.32.1
@@ -21,7 +230,7 @@ Release date: 2020-03-29
21
230
  ### Added
22
231
 
23
232
  * Support `delay` setting on click with Selenium
24
- * Implement rapid set for values longer thn 30 characters in text fields with Selenium
233
+ * Implement rapid set for values longer than 30 characters in text fields with Selenium
25
234
 
26
235
  ### Fixed
27
236
 
@@ -142,8 +351,8 @@ Release date: 2019-06-27
142
351
 
143
352
  ### Fixed
144
353
 
145
- * Woraround issue with chromedriver 76/77 in W3C mode losing mouse state during legacy drag. Only fixed if
146
- both source and target are simultaenously inside the viewport - Issue #2223
354
+ * Work around issue with chromedriver 76/77 in W3C mode losing mouse state during legacy drag. Only fixed if
355
+ both source and target are simultaneously inside the viewport - Issue #2223
147
356
  * Negative ancestor expectations/predicates were incorrectly checking siblings rather than ancestors
148
357
 
149
358
  # Version 3.24.0
@@ -422,7 +631,7 @@ Release date: 2018-10-23
422
631
 
423
632
  ### Fixed
424
633
 
425
- * Selector `css` expression definiton declared filters now work again
634
+ * Selector `css` expression definition declared filters now work again
426
635
  * Cleaned up warnings [Yuji Yaginuma]
427
636
  * 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
428
637
 
@@ -539,7 +748,7 @@ Release date: 2018-07-19
539
748
 
540
749
  ### Fixed
541
750
 
542
- * Make selenium driver :backspace clear stategy work even if caret location is in middle of field content [Champier Cyril]
751
+ * Make selenium driver :backspace clear strategy work even if caret location is in middle of field content [Champier Cyril]
543
752
  * Selenium issue with fieldset nested in disabled fieldset not being considered disabled
544
753
  * `Session#evaluate_script` and `Element#evaluate_script` now strip leading/trailing whitespace from scripts [Ian Lesperance]
545
754
 
@@ -638,7 +847,7 @@ Release date: 2018-04-13
638
847
  ### Fixes
639
848
 
640
849
  * Fix expression filter descriptions in some selector failure messages
641
- * Fix compounding of negated matechers - Issue #2010
850
+ * Fix compounding of negated matchers - Issue #2010
642
851
 
643
852
  # Version 3.0.1
644
853
  Release date: 2018-04-06
@@ -665,7 +874,7 @@ Release date: 2018-03-23
665
874
 
666
875
  ### Changed
667
876
 
668
- * Visibile text whitespace is no longer fully normalized in favor of being more in line with the WebDriver spec for visible text
877
+ * Visible text whitespace is no longer fully normalized in favor of being more in line with the WebDriver spec for visible text
669
878
  * Drivers are expected to close extra windows when resetting the session
670
879
  * Selenium driver supports Date/Time when filling in date/time/datetime-local inputs
671
880
  * `current_url` returns the url for the top level browsing context
@@ -912,7 +1121,7 @@ Release date: 2016-12-05
912
1121
  * Options for clearing session/local storage on reset added to the Selenium driver
913
1122
  * Window size changes wait for the size to stabilize
914
1123
  * Defined return value for most actions
915
- * Ignore specific error when qutting selenium driver instance - Issue #1773 [Dylan Reichstadt, Thomas Walpole]
1124
+ * Ignore specific error when quitting selenium driver instance - Issue #1773 [Dylan Reichstadt, Thomas Walpole]
916
1125
  * Warn on selenium unknown errors rather than raising when quitting driver [Adam Pohorecki, Thomas Walpole]
917
1126
  * Capybara::Result#each now returns an `Enumerator` when called without a block - Issue #1777 [Thomas Walpole]
918
1127
 
@@ -974,7 +1183,7 @@ Release date: 2016-09-19
974
1183
 
975
1184
  ### Fixed
976
1185
 
977
- * Issue with rack-test driver and obselete mime-types when using `#attach_file` - Issue #1756 [Thomas Walpole]
1186
+ * Issue with rack-test driver and obsolete mime-types when using `#attach_file` - Issue #1756 [Thomas Walpole]
978
1187
 
979
1188
  ### Added
980
1189
 
@@ -1041,7 +1250,7 @@ Release date: 2016-04-07
1041
1250
 
1042
1251
  ### Added
1043
1252
 
1044
- * Capybara now waits for requests to Capybaras server to complete while restting the session [John Hawthorn, Thomas Walpole]
1253
+ * Capybara now waits for requests to Capybaras server to complete while resetting the session [John Hawthorn, Thomas Walpole]
1045
1254
  * Capybara.reuse_server option to allow disabling of sharing server instance between sessions [Thomas Walpole]
1046
1255
  * :multiple filter added to relevant selectors [Thomas Walpole]
1047
1256
  * Provided server registrations for :webrick and :puma. Capybara.server = :puma for testing with Rails 5 [Thomas Walpole]
@@ -1055,7 +1264,7 @@ Release date: 2016-04-07
1055
1264
 
1056
1265
  # Version 2.6.2
1057
1266
 
1058
- Relase date: 2016-01-27
1267
+ Release date: 2016-01-27
1059
1268
 
1060
1269
  ### Fixed
1061
1270
 
@@ -1071,7 +1280,7 @@ Release date: 2016-01-27
1071
1280
 
1072
1281
  # Version 2.6.0
1073
1282
 
1074
- Relase date: 2016-01-17
1283
+ Release date: 2016-01-17
1075
1284
 
1076
1285
  ### Fixed
1077
1286
 
@@ -1135,7 +1344,7 @@ Release date: 2014-10-13
1135
1344
 
1136
1345
  # Version 2.4.3
1137
1346
 
1138
- Relase date: 2014-09-21
1347
+ Release date: 2014-09-21
1139
1348
 
1140
1349
  ### Fixed
1141
1350
 
@@ -1601,8 +1810,8 @@ Release date: 2011-06-14
1601
1810
  * Rack::Test driver honours maxlength on input fields [Guilherme Carvalho]
1602
1811
  * Rack::Test now works as expected with domains and subdomains [Jonas Nicklas]
1603
1812
  * Session is reset more thoroughly between tests. [Jonas Nicklas]
1604
- * Raise error when uploading non-existant file [Jonas Nicklas]
1605
- * Rack reponse body should respond to #each [Piotr Sarnacki]
1813
+ * Raise error when uploading non-existent file [Jonas Nicklas]
1814
+ * Rack response body should respond to #each [Piotr Sarnacki]
1606
1815
  * Deprecation warnings with selenium webdriver 0.2.0 [Aaron Gibraltar]
1607
1816
  * Selenium Chrome no longer YELLS tagname [Carl Jackson & David W. Frank]
1608
1817
  * Capybara no longer strips encoding before sending to Rack [Jonas Nicklas]
@@ -1744,7 +1953,7 @@ Release date: 2010-05-12
1744
1953
 
1745
1954
  Release date: 2010-04-09
1746
1955
 
1747
- This is a drop in compatible maintainance release. It's mostly
1956
+ This is a drop in compatible maintenance release. It's mostly
1748
1957
  important for driver authors.
1749
1958
 
1750
1959
  ### Added
@@ -1763,7 +1972,7 @@ important for driver authors.
1763
1972
 
1764
1973
  Release date: 2010-03-22
1765
1974
 
1766
- This is a maintainance release with minor bug fixes, should be
1975
+ This is a maintenance release with minor bug fixes, should be
1767
1976
  drop in compatible.
1768
1977
 
1769
1978
  ### Added
@@ -1810,4 +2019,3 @@ too many users, please read the release notes carefully!
1810
2019
  * clicking links where the image's alt attribute contains the text is now possible
1811
2020
  * within_fieldset and within_table work when the default selector is CSS
1812
2021
  * boolean attributes work the same across drivers (return true/false)
1813
-
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.32.x version of Capybara.
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.7.0 or later. To install, add this line to your
80
78
  `Gemfile` and run `bundle install`:
81
79
 
82
80
  ```ruby
@@ -149,10 +147,12 @@ 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
 
154
+ If you are using Rails system specs please see [their documentation](https://relishapp.com/rspec/rspec-rails/docs/system-specs/system-spec#system-specs-driven-by-selenium-chrome-headless) for selecting the driver you wish to use.
155
+
156
156
  If you are not using Rails, tag all the example groups in which you want to use
157
157
  Capybara with `type: :feature`.
158
158
 
@@ -161,7 +161,7 @@ You can now write your specs like so:
161
161
  ```ruby
162
162
  describe "the signin process", type: :feature do
163
163
  before :each do
164
- User.make(email: 'user@example.com', password: 'password')
164
+ User.create(email: 'user@example.com', password: 'password')
165
165
  end
166
166
 
167
167
  it "signs me in" do
@@ -192,7 +192,7 @@ Capybara also comes with a built in DSL for creating descriptive acceptance test
192
192
  ```ruby
193
193
  feature "Signing in" do
194
194
  background do
195
- User.make(email: 'user@example.com', password: 'caplin')
195
+ User.create(email: 'user@example.com', password: 'caplin')
196
196
  end
197
197
 
198
198
  scenario "Signing in with correct credentials" do
@@ -205,7 +205,7 @@ feature "Signing in" do
205
205
  expect(page).to have_content 'Success'
206
206
  end
207
207
 
208
- given(:other_user) { User.make(email: 'other@example.com', password: 'rous') }
208
+ given(:other_user) { User.create(email: 'other@example.com', password: 'rous') }
209
209
 
210
210
  scenario "Signing in as another user" do
211
211
  visit '/sessions/new'
@@ -260,6 +260,8 @@ end
260
260
 
261
261
  ## <a name="using-capybara-with-minitest"></a>Using Capybara with Minitest
262
262
 
263
+ * If you are using Rails system tests please see their documentation for information on selecting the driver you wish to use.
264
+
263
265
  * If you are using Rails, but not using Rails system tests, add the following code in your `test_helper.rb`
264
266
  file to make Capybara available in all test cases deriving from
265
267
  `ActionDispatch::IntegrationTest`:
@@ -334,7 +336,7 @@ By default, Capybara uses the `:rack_test` driver, which is fast but limited: it
334
336
  does not support JavaScript, nor is it able to access HTTP resources outside of
335
337
  your Rack application, such as remote APIs and OAuth services. To get around
336
338
  these limitations, you can set up a different default driver for your features.
337
- For example if you'd prefer to run everything in Selenium, you could do:
339
+ For example, if you'd prefer to run everything in Selenium, you could do:
338
340
 
339
341
  ```ruby
340
342
  Capybara.default_driver = :selenium # :selenium_chrome and :selenium_chrome_headless are also registered
@@ -628,7 +630,7 @@ JS
628
630
 
629
631
  ### <a name="modals"></a>Modals
630
632
 
631
- In drivers which support it, you can accept, dismiss and respond to alerts, confirms and prompts.
633
+ In drivers which support it, you can accept, dismiss and respond to alerts, confirms, and prompts.
632
634
 
633
635
  You can accept or dismiss alert messages by wrapping the code that produces an alert in a block:
634
636
 
@@ -779,7 +781,7 @@ expect(page).to have_content('baz')
779
781
  If clicking on the *foo* link triggers an asynchronous process, such as
780
782
  an Ajax request, which, when complete will add the *bar* link to the page,
781
783
  clicking on the *bar* link would be expected to fail, since that link doesn't
782
- exist yet. However Capybara is smart enough to retry finding the link for a
784
+ exist yet. However, Capybara is smart enough to retry finding the link for a
783
785
  brief period of time before giving up and throwing an error. The same is true of
784
786
  the next line, which looks for the content *baz* on the page; it will retry
785
787
  looking for that content for a brief time. You can adjust how long this period
@@ -793,13 +795,25 @@ Be aware that because of this behaviour, the following two statements are **not*
793
795
  equivalent, and you should **always** use the latter!
794
796
 
795
797
  ```ruby
796
- !page.has_xpath?('a')
797
- page.has_no_xpath?('a')
798
+ # Given use of a driver where the page is loaded when visit returns
799
+ # and that Capybara.predicates_wait is `true`
800
+ # consider a page where the `a` tag is removed through AJAX after 1s
801
+ visit(some_path)
802
+ !page.has_xpath?('a') # is false
803
+ page.has_no_xpath?('a') # is true
798
804
  ```
799
805
 
800
- The former would immediately fail because the content has not yet been removed.
801
- Only the latter would wait for the asynchronous process to remove the content
802
- from the page.
806
+ First expression:
807
+ - `has_xpath?('a')` is called right after `visit` returns. It is `true` because the link has not yet been removed
808
+ - Capybara does not wait upon successful predicates/assertions, therefore **has_xpath? returns `true` immediately**
809
+ - The expression returns `false` (because it is negated with the leading `!`)
810
+
811
+ Second expression:
812
+ - `has_no_xpath?('a')` is called right after `visit` returns. It is `false` because the link has not yet been removed.
813
+ - Capybara waits upon failed predicates/assertions, therefore **has_no_xpath? does not return `false` immediately**
814
+ - Capybara will periodically re-check the predicate/assertion up to the `default_max_wait_time` defined
815
+ - after 1s, the predicate becomes `true` (because the link has been removed)
816
+ - The expression returns `true`
803
817
 
804
818
  Capybara's RSpec matchers, however, are smart enough to handle either form.
805
819
  The two following statements are functionally equivalent:
@@ -1055,6 +1069,13 @@ additional info about how the underlying driver can be configured.
1055
1069
  are testing for specific server errors and using multiple sessions make sure to test for the
1056
1070
  errors using the initial session (usually :default)
1057
1071
 
1072
+ * If WebMock is enabled, you may encounter a "Too many open files"
1073
+ error. A simple `page.find` call may cause thousands of HTTP requests
1074
+ until the timeout occurs. By default, WebMock will cause each of these
1075
+ requests to spawn a new connection. To work around this problem, you
1076
+ may need to [enable WebMock's `net_http_connect_on_start: true`
1077
+ parameter](https://github.com/bblimke/webmock/blob/master/README.md#connecting-on-nethttpstart).
1078
+
1058
1079
  ## <a name="threadsafe"></a>"Threadsafe" mode
1059
1080
 
1060
1081
  In normal mode most of Capybara's configuration options are global settings which can cause issues
@@ -7,13 +7,13 @@ module Capybara
7
7
  class Config
8
8
  extend Forwardable
9
9
 
10
- OPTIONS = %i[app reuse_server threadsafe server default_driver javascript_driver allow_gumbo].freeze
10
+ OPTIONS = %i[
11
+ app reuse_server threadsafe server default_driver javascript_driver use_html5_parsing allow_gumbo
12
+ ].freeze
11
13
 
12
- attr_accessor :app
13
- attr_reader :reuse_server, :threadsafe
14
- attr_reader :session_options
14
+ attr_accessor :app, :use_html5_parsing
15
+ attr_reader :reuse_server, :threadsafe, :session_options # rubocop:disable Style/BisectedAttrAccessor
15
16
  attr_writer :default_driver, :javascript_driver
16
- attr_accessor :allow_gumbo
17
17
 
18
18
  SessionConfig::OPTIONS.each do |method|
19
19
  def_delegators :session_options, method, "#{method}="
@@ -24,7 +24,7 @@ module Capybara
24
24
  @javascript_driver = nil
25
25
  end
26
26
 
27
- attr_writer :reuse_server
27
+ attr_writer :reuse_server # rubocop:disable Style/BisectedAttrAccessor
28
28
 
29
29
  def threadsafe=(bool)
30
30
  if (bool != threadsafe) && Session.instance_created?
@@ -83,12 +83,22 @@ module Capybara
83
83
  @javascript_driver || :selenium
84
84
  end
85
85
 
86
- def deprecate(method, alternate_method, once = false)
86
+ def deprecate(method, alternate_method, once: false)
87
87
  @deprecation_notified ||= {}
88
88
  unless once && @deprecation_notified[method]
89
- warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead"
89
+ Capybara::Helpers.warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead: #{Capybara::Helpers.filter_backtrace(caller)}"
90
90
  end
91
91
  @deprecation_notified[method] = true
92
92
  end
93
+
94
+ def allow_gumbo=(val)
95
+ deprecate('allow_gumbo=', 'use_html5_parsing=')
96
+ self.use_html5_parsing = val
97
+ end
98
+
99
+ def allow_gumbo
100
+ deprecate('allow_gumbo', 'use_html5_parsing')
101
+ use_html5_parsing
102
+ end
93
103
  end
94
104
  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,14 @@ 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
+
66
+ def active_element
67
+ raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#active_element'
68
+ end
69
+
62
70
  ##
63
71
  #
64
72
  # @param frame [Capybara::Node::Element, :parent, :top] The iframe element to switch to
@@ -125,6 +125,10 @@ module Capybara
125
125
  raise NotSupportedByDriverError, 'Capybara::Driver::Node#trigger'
126
126
  end
127
127
 
128
+ def shadow_root
129
+ raise NotSupportedByDriverError, 'Capybara::Driver::Node#shadow_root'
130
+ end
131
+
128
132
  def inspect
129
133
  %(#<#{self.class} tag="#{tag_name}" path="#{path}">)
130
134
  rescue NotSupportedByDriverError
@@ -132,7 +136,7 @@ module Capybara
132
136
  end
133
137
 
134
138
  def ==(other)
135
- raise NotSupportedByDriverError, 'Capybara::Driver::Node#=='
139
+ eql?(other) || (other.respond_to?(:native) && native == other.native)
136
140
  end
137
141
  end
138
142
  end
data/lib/capybara/dsl.rb CHANGED
@@ -47,17 +47,11 @@ module Capybara
47
47
  end
48
48
 
49
49
  Session::DSL_METHODS.each do |method|
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
50
+ class_eval <<~METHOD, __FILE__, __LINE__ + 1
51
+ def #{method}(...)
52
+ page.method("#{method}").call(...)
59
53
  end
60
- end
54
+ METHOD
61
55
  end
62
56
  end
63
57
 
@@ -15,7 +15,7 @@ module Capybara
15
15
  # @return [String] Normalized text
16
16
  #
17
17
  def normalize_whitespace(text)
18
- warn 'DEPRECATED: Capybara::Helpers::normalize_whitespace is deprecated, please update your driver'
18
+ Capybara::Helpers.warn 'DEPRECATED: Capybara::Helpers::normalize_whitespace is deprecated, please update your driver'
19
19
  text.to_s.gsub(/[[:space:]]+/, ' ').strip
20
20
  end
21
21
 
@@ -70,7 +70,26 @@ module Capybara
70
70
  count == 1 ? singular : plural
71
71
  end
72
72
 
73
- if defined?(Process::CLOCK_MONOTONIC)
73
+ def filter_backtrace(trace)
74
+ return 'No backtrace' unless trace
75
+
76
+ filter = %r{lib/capybara/|lib/rspec/|lib/minitest/|delegate.rb}
77
+ new_trace = trace.take_while { |line| line !~ filter }
78
+ new_trace = trace.grep_v(filter) if new_trace.empty?
79
+ new_trace = trace.dup if new_trace.empty?
80
+
81
+ new_trace.first.split(/:in /, 2).first
82
+ end
83
+
84
+ def warn(message, uplevel: 1)
85
+ Kernel.warn(message, uplevel: uplevel)
86
+ end
87
+
88
+ if defined?(Process::CLOCK_MONOTONIC_RAW)
89
+ def monotonic_time; Process.clock_gettime Process::CLOCK_MONOTONIC_RAW; end
90
+ elsif defined?(Process::CLOCK_MONOTONIC_PRECISE)
91
+ def monotonic_time; Process.clock_gettime Process::CLOCK_MONOTONIC_PRECISE; end
92
+ elsif defined?(Process::CLOCK_MONOTONIC)
74
93
  def monotonic_time; Process.clock_gettime Process::CLOCK_MONOTONIC; end
75
94
  else
76
95
  def monotonic_time; Time.now.to_f; end