capybara 3.25.0 → 3.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +45 -0
  3. data/README.md +1 -1
  4. data/lib/capybara/minitest.rb +29 -29
  5. data/lib/capybara/node/element.rb +52 -18
  6. data/lib/capybara/node/matchers.rb +6 -6
  7. data/lib/capybara/node/simple.rb +2 -1
  8. data/lib/capybara/queries/ancestor_query.rb +5 -9
  9. data/lib/capybara/queries/selector_query.rb +2 -2
  10. data/lib/capybara/queries/sibling_query.rb +4 -10
  11. data/lib/capybara/queries/text_query.rb +7 -1
  12. data/lib/capybara/registrations/patches/puma_ssl.rb +27 -0
  13. data/lib/capybara/registrations/servers.rb +7 -1
  14. data/lib/capybara/rspec/matchers.rb +65 -43
  15. data/lib/capybara/selector.rb +6 -1
  16. data/lib/capybara/selector/definition/fillable_field.rb +1 -1
  17. data/lib/capybara/selector/definition/option.rb +1 -1
  18. data/lib/capybara/selector/regexp_disassembler.rb +7 -0
  19. data/lib/capybara/selenium/atoms/isDisplayed.min.js +1 -1
  20. data/lib/capybara/selenium/atoms/src/isDisplayed.js +9 -9
  21. data/lib/capybara/selenium/driver.rb +11 -3
  22. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +9 -8
  23. data/lib/capybara/selenium/driver_specializations/edge_driver.rb +14 -10
  24. data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +16 -0
  25. data/lib/capybara/selenium/driver_specializations/safari_driver.rb +0 -4
  26. data/lib/capybara/selenium/extensions/html5_drag.rb +10 -5
  27. data/lib/capybara/selenium/node.rb +29 -2
  28. data/lib/capybara/selenium/nodes/chrome_node.rb +41 -9
  29. data/lib/capybara/selenium/nodes/edge_node.rb +28 -12
  30. data/lib/capybara/selenium/nodes/firefox_node.rb +16 -4
  31. data/lib/capybara/selenium/nodes/safari_node.rb +0 -4
  32. data/lib/capybara/selenium/patches/is_displayed.rb +16 -0
  33. data/lib/capybara/server.rb +4 -0
  34. data/lib/capybara/session.rb +4 -4
  35. data/lib/capybara/spec/session/has_field_spec.rb +18 -0
  36. data/lib/capybara/spec/session/has_text_spec.rb +6 -0
  37. data/lib/capybara/spec/session/node_spec.rb +128 -23
  38. data/lib/capybara/spec/views/form.erb +6 -1
  39. data/lib/capybara/spec/views/with_html.erb +10 -0
  40. data/lib/capybara/spec/views/with_jstree.erb +26 -0
  41. data/lib/capybara/version.rb +1 -1
  42. data/spec/basic_node_spec.rb +6 -6
  43. data/spec/capybara_spec.rb +28 -28
  44. data/spec/filter_set_spec.rb +5 -5
  45. data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -1
  46. data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
  47. data/spec/rack_test_spec.rb +9 -9
  48. data/spec/regexp_dissassembler_spec.rb +12 -2
  49. data/spec/rspec/shared_spec_matchers.rb +2 -2
  50. data/spec/rspec_spec.rb +1 -1
  51. data/spec/selector_spec.rb +15 -15
  52. data/spec/selenium_spec_chrome.rb +38 -0
  53. data/spec/selenium_spec_chrome_remote.rb +0 -6
  54. data/spec/selenium_spec_edge.rb +14 -15
  55. data/spec/selenium_spec_firefox.rb +1 -1
  56. data/spec/selenium_spec_firefox_remote.rb +0 -6
  57. data/spec/selenium_spec_ie.rb +1 -6
  58. data/spec/server_spec.rb +26 -17
  59. data/spec/session_spec.rb +4 -4
  60. data/spec/shared_selenium_node.rb +36 -0
  61. data/spec/shared_selenium_session.rb +2 -0
  62. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 439a641ea3d9a06bcc674c159c3ef16612fb29874e71f11ef7bb2d0e73382892
4
- data.tar.gz: a5e57dfb62e3682a87f05650a13945545a61183a84a15498390d07aa3ec6e4ed
3
+ metadata.gz: 59f170c7004d4936ffb0d136a4dd0755a9c1ec5870f6bf1114d693b99a8fed51
4
+ data.tar.gz: 955e163359d522952afdc7d776458667f97aa053e6eb704320733eae8340544a
5
5
  SHA512:
6
- metadata.gz: d50ab813eecabef7465c9a42904174f65eefe6dc8e0f92fea59d523753582c1797a1a87880a1d9805edb8f74e33585314841d6fac7abcf2781a627ac9703191e
7
- data.tar.gz: 0d4f2b360e528a3fae6357072592ac5295cb500d68251d23bc66a014fc62528473e960b4049d4e24a5339a8a41f02f15c70b7ae59b5f51ebfb1a7369afa47f27
6
+ metadata.gz: 13d33c4977455c5d2e9a5aa7532ffed98573795a1528685ded75574dfabd58512f5d3e71d3582d8155fe4325209ba3bbde3246a29b4436de573c5b492dffe1cc
7
+ data.tar.gz: 52b33d646ec5c86b61a04b7f2c354a1d1e77d1c363b0ba8d19e7ad1b48679a53078766c8f018f1d7f223b730d9b4d951f005a689a3f143999fdeead4c522242c
data/History.md CHANGED
@@ -1,3 +1,48 @@
1
+ # Version 3.28.0
2
+ Release date: 2019-08-03
3
+
4
+ ### Added
5
+
6
+ * Allow forcing HTML5 or legacy dragging via the `:html5` option to `drag_to` when using Selenium with Chrome or Firefox
7
+ * Autodetection of drag type interprets not seeing the mousedown event as legacy.
8
+ * HTML5 form validation `:valid` node filter added to `:field` and `:fillable_field` selectors
9
+ * When using Capybara registered :puma server - patches Puma 4.0.x to fix SSL connection behavior. Removes
10
+ default `queue_requests` setting - Issue #2227
11
+
12
+ # Version 3.27.0
13
+ Release date: 2019-07-28
14
+
15
+ ### Added
16
+
17
+ * Allow to use chromedriver/geckodriver native `is_element_displayed` endpoint via Selenium
18
+ driver `native_displayed` option for performance reasons. Disabled by default due to endpoints
19
+ currently not handling <details> element descendants visibility correctly.
20
+
21
+ ### Fixed
22
+
23
+ * Ignore negative lookahead/lookbehind regex when performing initial XPath text matching
24
+ * Reloading of elements found via `ancestor` and `sibling`
25
+ * Only default puma settings to `queue_requests: false` when using SSL
26
+ * Visibility of descendants of <details> elements is correctly determined when using rack_test
27
+ and the selenium driver with Capybara optimized atoms
28
+ * local/session storage clearance in Chrome when clearing only one of them - Issue #2233
29
+
30
+ # Version 3.26.0
31
+ Release date: 2019-07-15
32
+
33
+ ### Added
34
+
35
+ * `w3c_click_offset` configuration option applies to `right_click` and `double_click` as well as `click`
36
+ * Warning when passing `nil` to the text/content assertions/expectations
37
+ * `Session#server_url` returns the base url the AUT is being run at (when controlled by Capybara)
38
+ * `option` selector type accepts an integer as locator
39
+
40
+ ### Fixed
41
+
42
+ * Default puma server registration now specifies `queue_requests: false` - Issue #2227
43
+ * Workaround issue with FF 68 and hanging during reset if a system modal is visible
44
+ * Don't expand file path if it's already absolute - Issue #2228
45
+
1
46
  # Version 3.25.0
2
47
  Release date: 2019-06-27
3
48
 
data/README.md CHANGED
@@ -7,7 +7,7 @@
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.25.x version of Capybara
10
+ **Note** You are viewing the README for the 3.28.x version of Capybara.
11
11
 
12
12
  Capybara helps you test web applications by simulating how a real user would
13
13
  interact with your app. It is agnostic about the driver running your tests and
@@ -9,38 +9,38 @@ module Capybara
9
9
  ## Assert text exists
10
10
  #
11
11
  # @!method assert_text
12
- # see {Capybara::Node::Matchers#assert_text}
12
+ # @see Capybara::Node::Matchers#assert_text
13
13
 
14
14
  ## Assert text does not exist
15
15
  #
16
16
  # @!method assert_no_text
17
- # see {Capybara::Node::Matchers#assert_no_text}
17
+ # @see Capybara::Node::Matchers#assert_no_text
18
18
 
19
19
  ##
20
20
  # Assertion that page title does match
21
21
  #
22
22
  # @!method assert_title
23
- # see {Capybara::Node::DocumentMatchers#assert_title}
23
+ # @see Capybara::Node::DocumentMatchers#assert_title
24
24
 
25
25
  ##
26
26
  # Assertion that page title does not match
27
27
  #
28
28
  # @!method refute_title
29
29
  # @!method assert_no_title
30
- # see {Capybara::Node::DocumentMatchers#assert_no_title}
30
+ # @see Capybara::Node::DocumentMatchers#assert_no_title
31
31
 
32
32
  ##
33
33
  # Assertion that current path matches
34
34
  #
35
35
  # @!method assert_current_path
36
- # see {Capybara::SessionMatchers#assert_current_path}
36
+ # @see Capybara::SessionMatchers#assert_current_path
37
37
 
38
38
  ##
39
39
  # Assertion that current page does not match
40
40
  #
41
41
  # @!method refute_current_path
42
42
  # @!method assert_no_current_path
43
- # see {Capybara::SessionMatchers#assert_no_current_path}
43
+ # @see Capybara::SessionMatchers#assert_no_current_path
44
44
 
45
45
  %w[text no_text title no_title current_path no_current_path].each do |assertion_name|
46
46
  class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
@@ -64,37 +64,37 @@ module Capybara
64
64
  ## Assert selector exists on page
65
65
  #
66
66
  # @!method assert_selector
67
- # see {Capybara::Node::Matchers#assert_selector}
67
+ # @see Capybara::Node::Matchers#assert_selector
68
68
 
69
69
  ## Assert selector does not exist on page
70
70
  #
71
71
  # @!method assert_no_selector
72
- # see {Capybara::Node::Matchers#assert_no_selector}
72
+ # @see Capybara::Node::Matchers#assert_no_selector
73
73
 
74
74
  ## Assert element matches selector
75
75
  #
76
76
  # @!method assert_matches_selector
77
- # see {Capybara::Node::Matchers#assert_matches_selector}
77
+ # @see Capybara::Node::Matchers#assert_matches_selector
78
78
 
79
79
  ## Assert element does not match selector
80
80
  #
81
81
  # @!method assert_xpath
82
- # see {Capybara::Node::Matchers#assert_not_matches_selector}
82
+ # @see Capybara::Node::Matchers#assert_not_matches_selector
83
83
 
84
84
  ## Assert element has the provided CSS styles
85
85
  #
86
86
  # @!method assert_matches_style
87
- # see {Capybara::Node::Matchers#assert_matches_style}
87
+ # @see Capybara::Node::Matchers#assert_matches_style
88
88
 
89
89
  ## Assert element has a matching sibling
90
90
  #
91
91
  # @!method assert_sibling
92
- # see {Capybara::Node::Matchers#assert_sibling}
92
+ # @see Capybara::Node::Matchers#assert_sibling
93
93
 
94
94
  ## Assert element has a matching ancestor
95
95
  #
96
96
  # @!method assert_ancestor
97
- # see {Capybara::Node::Matchers#assert_ancestor}
97
+ # @see Capybara::Node::Matchers#assert_ancestor
98
98
 
99
99
  %w[selector no_selector matches_style
100
100
  all_of_selectors none_of_selectors any_of_selectors
@@ -163,72 +163,72 @@ module Capybara
163
163
  # Assertion that there is xpath
164
164
  #
165
165
  # @!method assert_xpath
166
- # see {Capybara::Node::Matchers#has_xpath?}
166
+ # @see Capybara::Node::Matchers#has_xpath?
167
167
 
168
168
  ##
169
169
  # Assertion that there is no xpath
170
170
  #
171
171
  # @!method refute_xpath
172
172
  # @!method assert_no_xpath
173
- # see {Capybara::Node::Matchers#has_no_xpath?}
173
+ # @see Capybara::Node::Matchers#has_no_xpath?
174
174
 
175
175
  ##
176
176
  # Assertion that there is css
177
177
  #
178
178
  # @!method assert_css
179
- # see {Capybara::Node::Matchers#has_css?}
179
+ # @see Capybara::Node::Matchers#has_css?
180
180
 
181
181
  ##
182
182
  # Assertion that there is no css
183
183
  #
184
184
  # @!method refute_css
185
185
  # @!method assert_no_css
186
- # see {Capybara::Node::Matchers#has_no_css?}
186
+ # @see Capybara::Node::Matchers#has_no_css?
187
187
 
188
188
  ##
189
189
  # Assertion that there is link
190
190
  #
191
191
  # @!method assert_link
192
- # see {Capybara::Node::Matchers#has_link?}
192
+ # @see Capybara::Node::Matchers#has_link?
193
193
 
194
194
  ##
195
195
  # Assertion that there is no link
196
196
  #
197
197
  # @!method assert_no_link
198
198
  # @!method refute_link
199
- # see {Capybara::Node::Matchers#has_no_link?}
199
+ # @see Capybara::Node::Matchers#has_no_link?
200
200
 
201
201
  ##
202
202
  # Assertion that there is button
203
203
  #
204
204
  # @!method assert_button
205
- # see {Capybara::Node::Matchers#has_button?}
205
+ # @see Capybara::Node::Matchers#has_button?
206
206
 
207
207
  ##
208
208
  # Assertion that there is no button
209
209
  #
210
210
  # @!method refute_button
211
211
  # @!method assert_no_button
212
- # see {Capybara::Node::Matchers#has_no_button?}
212
+ # @see Capybara::Node::Matchers#has_no_button?
213
213
 
214
214
  ##
215
215
  # Assertion that there is field
216
216
  #
217
217
  # @!method assert_field
218
- # see {Capybara::Node::Matchers#has_field?}
218
+ # @see Capybara::Node::Matchers#has_field?
219
219
 
220
220
  ##
221
221
  # Assertion that there is no field
222
222
  #
223
223
  # @!method refute_field
224
224
  # @!method assert_no_field
225
- # see {Capybara::Node::Matchers#has_no_field?}
225
+ # @see Capybara::Node::Matchers#has_no_field?
226
226
 
227
227
  ##
228
228
  # Assertion that there is checked_field
229
229
  #
230
230
  # @!method assert_checked_field
231
- # see {Capybara::Node::Matchers#has_checked_field?}
231
+ # @see Capybara::Node::Matchers#has_checked_field?
232
232
 
233
233
  ##
234
234
  # Assertion that there is no checked_field
@@ -240,7 +240,7 @@ module Capybara
240
240
  # Assertion that there is unchecked_field
241
241
  #
242
242
  # @!method assert_unchecked_field
243
- # see {Capybara::Node::Matchers#has_unchecked_field?}
243
+ # @see Capybara::Node::Matchers#has_unchecked_field?
244
244
 
245
245
  ##
246
246
  # Assertion that there is no unchecked_field
@@ -252,27 +252,27 @@ module Capybara
252
252
  # Assertion that there is select
253
253
  #
254
254
  # @!method assert_select
255
- # see {Capybara::Node::Matchers#has_select?}
255
+ # @see Capybara::Node::Matchers#has_select?
256
256
 
257
257
  ##
258
258
  # Assertion that there is no select
259
259
  #
260
260
  # @!method refute_select
261
261
  # @!method assert_no_select
262
- # see {Capybara::Node::Matchers#has_no_select?}
262
+ # @see Capybara::Node::Matchers#has_no_select?
263
263
 
264
264
  ##
265
265
  # Assertion that there is table
266
266
  #
267
267
  # @!method assert_table
268
- # see {Capybara::Node::Matchers#has_table?}
268
+ # @see Capybara::Node::Matchers#has_table?
269
269
 
270
270
  ##
271
271
  # Assertion that there is no table
272
272
  #
273
273
  # @!method refute_table
274
274
  # @!method assert_no_table
275
- # see {Capybara::Node::Matchers#has_no_table?}
275
+ # @see Capybara::Node::Matchers#has_no_table?
276
276
 
277
277
  private
278
278
 
@@ -162,12 +162,10 @@ module Capybara
162
162
  # @option options [Integer] y Y coordinate to offset the click location. If {Capybara.configure w3c_click_offset} is `true` the
163
163
  # offset will be from the element center, otherwise it will be from the top left corner of the element
164
164
  # @return [Capybara::Node::Element] The element
165
- def click(*keys, wait: nil, **options)
166
- raise ArgumentError, 'You must specify both x: and y: for a click offset' if nil ^ options[:x] ^ options[:y]
167
-
168
- options[:offset] = :center if session_options.w3c_click_offset
169
- synchronize(wait) { base.click(Array(keys), options) }
170
- self
165
+ def click(*keys, **options)
166
+ perform_click_action(keys, options) do |k, opts|
167
+ base.click(k, opts)
168
+ end
171
169
  end
172
170
 
173
171
  ##
@@ -177,11 +175,10 @@ module Capybara
177
175
  # @macro action_waiting_behavior
178
176
  # @macro click_modifiers
179
177
  # @return [Capybara::Node::Element] The element
180
- def right_click(*keys, wait: nil, **offset)
181
- raise ArgumentError, 'You must specify both x: and y: for a click offset' if nil ^ offset[:x] ^ offset[:y]
182
-
183
- synchronize(wait) { base.right_click(keys, offset) }
184
- self
178
+ def right_click(*keys, **options)
179
+ perform_click_action(keys, options) do |k, opts|
180
+ base.right_click(k, opts)
181
+ end
185
182
  end
186
183
 
187
184
  ##
@@ -191,11 +188,10 @@ module Capybara
191
188
  # @macro action_waiting_behavior
192
189
  # @macro click_modifiers
193
190
  # @return [Capybara::Node::Element] The element
194
- def double_click(*keys, wait: nil, **offset)
195
- raise ArgumentError, 'You must specify both x: and y: for a click offset' if nil ^ offset[:x] ^ offset[:y]
196
-
197
- synchronize(wait) { base.double_click(keys, offset) }
198
- self
191
+ def double_click(*keys, **options)
192
+ perform_click_action(keys, options) do |k, opts|
193
+ base.double_click(k, opts)
194
+ end
199
195
  end
200
196
 
201
197
  ##
@@ -400,8 +396,13 @@ module Capybara
400
396
  #
401
397
  # @param [Capybara::Node::Element] node The element to drag to
402
398
  # @param [Hash] options Driver specific options for dragging. May not be supported by all drivers.
399
+ # @option options [Numeric] :delay (0.05) When using Chrome/Firefox with Selenium and HTML5 dragging this is the number
400
+ # of seconds between each stage of the drag.
401
+ # @option options [Boolean] :html5 When using Chrome/Firefox with Selenium enables to force the use of HTML5
402
+ # (true) or legacy (false) dragging. If not specified the driver will attempt to
403
+ # detect the correct method to use.
403
404
  #
404
- # @return [Capybara::Node::Element] The element
405
+ # @return [Capybara::Node::Element] The dragged element
405
406
  def drag_to(node, **options)
406
407
  synchronize { base.drag_to(node.base, **options) }
407
408
  self
@@ -514,11 +515,34 @@ module Capybara
514
515
  JS
515
516
  end
516
517
 
518
+ ##
519
+ #
520
+ # Toggle the elements background color between white and black for a period of time.
521
+ #
522
+ # @return [Capybara::Node::Element] The element
523
+ def flash
524
+ execute_script(<<~JS, 100)
525
+ async function flash(el, delay){
526
+ var old_bg = el.style.backgroundColor;
527
+ var colors = ["black", "white"];
528
+ for(var i=0; i<20; i++){
529
+ el.style.backgroundColor = colors[i % colors.length];
530
+ await new Promise(resolve => setTimeout(resolve, delay));
531
+ }
532
+ el.style.backgroundColor = old_bg;
533
+ }
534
+ flash(this, arguments[0]);
535
+ JS
536
+
537
+ self
538
+ end
539
+
517
540
  # @api private
518
541
  def reload
519
542
  if @allow_reload
520
543
  begin
521
- reloaded = query_scope.reload.first(@query.name, @query.locator, @query.options)
544
+ reloaded = @query.resolve_for(query_scope.reload)&.first
545
+
522
546
  @base = reloaded.base if reloaded
523
547
  rescue StandardError => e
524
548
  raise e unless catch_error?(e)
@@ -556,6 +580,16 @@ module Capybara
556
580
  return result;
557
581
  }).apply(this, arguments)
558
582
  JS
583
+
584
+ private
585
+
586
+ def perform_click_action(keys, wait: nil, **options)
587
+ raise ArgumentError, 'You must specify both x: and y: for a click offset' if nil ^ options[:x] ^ options[:y]
588
+
589
+ options[:offset] ||= :center if session_options.w3c_click_offset
590
+ synchronize(wait) { yield keys, options }
591
+ self
592
+ end
559
593
  end
560
594
  end
561
595
  end
@@ -141,8 +141,8 @@ module Capybara
141
141
  # or descendants of the current node. If options are provided, the assertion
142
142
  # will check that each locator is present with those options as well (other than `:wait`).
143
143
  #
144
- # page.assert_all_of_selectors(:custom, 'Tom', 'Joe', visible: all)
145
- # page.assert_all_of_selectors(:css, '#my_div', 'a.not_clicked')
144
+ # page.assert_all_of_selectors(:custom, 'Tom', 'Joe', visible: all)
145
+ # page.assert_all_of_selectors(:css, '#my_div', 'a.not_clicked')
146
146
  #
147
147
  # It accepts all options that {Capybara::Node::Finders#all} accepts,
148
148
  # such as `:text` and `:visible`.
@@ -162,8 +162,8 @@ module Capybara
162
162
  # or descendants of the current node. If options are provided, the assertion
163
163
  # will check that each locator is not present with those options as well (other than `:wait`).
164
164
  #
165
- # page.assert_none_of_selectors(:custom, 'Tom', 'Joe', visible: all)
166
- # page.assert_none_of_selectors(:css, '#my_div', 'a.not_clicked')
165
+ # page.assert_none_of_selectors(:custom, 'Tom', 'Joe', visible: all)
166
+ # page.assert_none_of_selectors(:css, '#my_div', 'a.not_clicked')
167
167
  #
168
168
  # It accepts all options that {Capybara::Node::Finders#all} accepts,
169
169
  # such as `:text` and `:visible`.
@@ -183,8 +183,8 @@ module Capybara
183
183
  # or descendants of the current node. If options are provided, the assertion
184
184
  # will check that each locator is present with those options as well (other than `:wait`).
185
185
  #
186
- # page.assert_any_of_selectors(:custom, 'Tom', 'Joe', visible: all)
187
- # page.assert_any_of_selectors(:css, '#my_div', 'a.not_clicked')
186
+ # page.assert_any_of_selectors(:custom, 'Tom', 'Joe', visible: all)
187
+ # page.assert_any_of_selectors(:css, '#my_div', 'a.not_clicked')
188
188
  #
189
189
  # It accepts all options that {Capybara::Node::Finders#all} accepts,
190
190
  # such as `:text` and `:visible`.
@@ -197,7 +197,8 @@ module Capybara
197
197
  x.ancestor_or_self[
198
198
  x.attr(:style)[x.contains('display:none') | x.contains('display: none')] |
199
199
  x.attr(:hidden) |
200
- x.qname.one_of('script', 'head')
200
+ x.qname.one_of('script', 'head') |
201
+ (~x.self(:summary) & XPath.parent(:details))
201
202
  ].boolean
202
203
  end.to_s.freeze
203
204
  end
@@ -3,20 +3,16 @@
3
3
  module Capybara
4
4
  module Queries
5
5
  class AncestorQuery < Capybara::Queries::SelectorQuery
6
- def initialize(*args)
7
- super
8
- @count_options = {}
9
- COUNT_KEYS.each do |key|
10
- @count_options[key] = @options.delete(key) if @options.key?(key)
11
- end
12
- end
13
-
14
6
  # @api private
15
7
  def resolve_for(node, exact = nil)
16
8
  @child_node = node
9
+
17
10
  node.synchronize do
18
11
  match_results = super(node.session.current_scope, exact)
19
- node.all(:xpath, XPath.ancestor, **@count_options) { |el| match_results.include?(el) }
12
+ ancestors = node.find_xpath(XPath.ancestor.to_s)
13
+ .map(&method(:to_element))
14
+ .select { |el| match_results.include?(el) }
15
+ Capybara::Result.new(ancestors, self)
20
16
  end
21
17
  end
22
18