capybara 3.29.0 → 3.30.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.
- checksums.yaml +4 -4
- data/History.md +19 -1
- data/README.md +1 -1
- data/lib/capybara/config.rb +7 -3
- data/lib/capybara/helpers.rb +3 -1
- data/lib/capybara/node/actions.rb +23 -19
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +3 -3
- data/lib/capybara/node/element.rb +10 -8
- data/lib/capybara/node/finders.rb +12 -10
- data/lib/capybara/node/matchers.rb +39 -33
- data/lib/capybara/node/simple.rb +3 -1
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/selector_query.rb +17 -4
- data/lib/capybara/queries/sibling_query.rb +1 -1
- data/lib/capybara/rack_test/browser.rb +4 -1
- data/lib/capybara/rack_test/driver.rb +1 -1
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/selector.rb +22 -16
- data/lib/capybara/selector/css.rb +1 -1
- data/lib/capybara/selector/definition.rb +2 -2
- data/lib/capybara/selector/definition/button.rb +7 -2
- data/lib/capybara/selector/definition/checkbox.rb +2 -2
- data/lib/capybara/selector/definition/css.rb +3 -1
- data/lib/capybara/selector/definition/datalist_input.rb +1 -1
- data/lib/capybara/selector/definition/datalist_option.rb +1 -1
- data/lib/capybara/selector/definition/element.rb +1 -1
- data/lib/capybara/selector/definition/field.rb +1 -1
- data/lib/capybara/selector/definition/file_field.rb +1 -1
- data/lib/capybara/selector/definition/fillable_field.rb +1 -1
- data/lib/capybara/selector/definition/label.rb +3 -1
- data/lib/capybara/selector/definition/radio_button.rb +2 -2
- data/lib/capybara/selector/definition/select.rb +1 -1
- data/lib/capybara/selector/definition/table.rb +5 -2
- data/lib/capybara/selector/filter_set.rb +11 -9
- data/lib/capybara/selector/filters/base.rb +6 -1
- data/lib/capybara/selector/filters/locator_filter.rb +1 -1
- data/lib/capybara/selector/selector.rb +4 -2
- data/lib/capybara/selenium/driver.rb +19 -11
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +2 -2
- data/lib/capybara/selenium/extensions/html5_drag.rb +6 -5
- data/lib/capybara/selenium/node.rb +6 -4
- data/lib/capybara/selenium/nodes/chrome_node.rb +7 -3
- data/lib/capybara/selenium/nodes/edge_node.rb +3 -1
- data/lib/capybara/selenium/nodes/firefox_node.rb +1 -1
- data/lib/capybara/server.rb +15 -3
- data/lib/capybara/server/checker.rb +1 -1
- data/lib/capybara/server/middleware.rb +20 -10
- data/lib/capybara/session.rb +10 -8
- data/lib/capybara/session/config.rb +6 -2
- data/lib/capybara/session/matchers.rb +6 -6
- data/lib/capybara/spec/public/test.js +11 -0
- data/lib/capybara/spec/session/all_spec.rb +15 -0
- data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
- data/lib/capybara/spec/session/assert_text_spec.rb +4 -0
- data/lib/capybara/spec/session/click_button_spec.rb +5 -0
- data/lib/capybara/spec/session/find_spec.rb +20 -0
- data/lib/capybara/spec/session/has_table_spec.rb +51 -5
- data/lib/capybara/spec/session/has_text_spec.rb +31 -0
- data/lib/capybara/spec/session/node_spec.rb +15 -0
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
- data/lib/capybara/spec/session/selectors_spec.rb +15 -2
- data/lib/capybara/spec/views/form.erb +5 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/dsl_spec.rb +2 -2
- data/spec/minitest_spec_spec.rb +46 -46
- data/spec/regexp_dissassembler_spec.rb +45 -37
- data/spec/result_spec.rb +3 -3
- data/spec/rspec/features_spec.rb +1 -0
- data/spec/rspec/shared_spec_matchers.rb +3 -3
- data/spec/rspec_spec.rb +4 -4
- data/spec/selenium_spec_chrome.rb +3 -3
- data/spec/selenium_spec_firefox.rb +7 -2
- data/spec/server_spec.rb +42 -0
- data/spec/session_spec.rb +1 -1
- data/spec/shared_selenium_node.rb +3 -3
- data/spec/shared_selenium_session.rb +8 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a441a0ffad497da4d5342b4a84c165d0922f92a049aa7035db212f210a1175c
|
4
|
+
data.tar.gz: c24b692401fc4eb28d73bdee5dc8f20b01d6cca582b0d94a4e015ac35485bc63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3003c43d66f8cf415de12e9c9db95c5a60022aa10d63c3372074763049c7719041162eee9bb99fec17a7bf4190d252812b5d1513df3f22a586501f9f671dbea1
|
7
|
+
data.tar.gz: de605e659b3c0e78065acd429e3d40c1e7758840b8cb8dd417229d440581b8363535d00a4193c51a2561a2ccde8b57b832d8176a8fb3b932a46e6682d161ddbd
|
data/History.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
|
+
# Version 3.30.0
|
2
|
+
Release date: 2019-12-24
|
3
|
+
|
4
|
+
### Added
|
5
|
+
|
6
|
+
* Display pending requests when they don't complete in time [Juan Carlos Medina]
|
7
|
+
* :order option in selector queries - set to :reverse to for reverse document order results
|
8
|
+
* Support regexp for :name and :placeholder options in selectors that import filters from
|
9
|
+
_field filter set
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
* Issue around automatic port assignment - Issue #2245
|
14
|
+
* Label selector when label has no id - Issue #2260
|
15
|
+
* Preserve clientX/clientY in Selenium HTML5 drag emulation [Nicolò G.]
|
16
|
+
* table selector using :with_cols option if last specified column matched but others didn't - Issue #2287
|
17
|
+
* Some tests updated for Ruby 2.7 behavior change around keyword args
|
18
|
+
|
1
19
|
# Version 3.29.0
|
2
|
-
Release date:
|
20
|
+
Release date: 2019-09-02
|
3
21
|
|
4
22
|
### Added
|
5
23
|
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
[](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
8
8
|
[](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.
|
10
|
+
**Note** You are viewing the README for the 3.30.x Capybara release.
|
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
|
data/lib/capybara/config.rb
CHANGED
@@ -27,7 +27,9 @@ module Capybara
|
|
27
27
|
attr_writer :reuse_server
|
28
28
|
|
29
29
|
def threadsafe=(bool)
|
30
|
-
|
30
|
+
if (bool != threadsafe) && Session.instance_created?
|
31
|
+
raise 'Threadsafe setting cannot be changed once a session is created'
|
32
|
+
end
|
31
33
|
|
32
34
|
@threadsafe = bool
|
33
35
|
end
|
@@ -59,7 +61,7 @@ module Capybara
|
|
59
61
|
@server = if name.respond_to? :call
|
60
62
|
name
|
61
63
|
elsif options
|
62
|
-
proc { |app, port, host| Capybara.servers[name.to_sym].call(app, port, host, options) }
|
64
|
+
proc { |app, port, host| Capybara.servers[name.to_sym].call(app, port, host, **options) }
|
63
65
|
else
|
64
66
|
Capybara.servers[name.to_sym]
|
65
67
|
end
|
@@ -83,7 +85,9 @@ module Capybara
|
|
83
85
|
|
84
86
|
def deprecate(method, alternate_method, once = false)
|
85
87
|
@deprecation_notified ||= {}
|
86
|
-
|
88
|
+
unless once && @deprecation_notified[method]
|
89
|
+
warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead"
|
90
|
+
end
|
87
91
|
@deprecation_notified[method] = true
|
88
92
|
end
|
89
93
|
end
|
data/lib/capybara/helpers.rb
CHANGED
@@ -87,7 +87,9 @@ module Capybara
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def expired?
|
90
|
-
|
90
|
+
if stalled?
|
91
|
+
raise Capybara::FrozenInTime, 'Time appears to be frozen. Capybara does not work with libraries which freeze time, consider using time travelling instead'
|
92
|
+
end
|
91
93
|
|
92
94
|
current - @start >= @expire_in
|
93
95
|
end
|
@@ -23,7 +23,7 @@ module Capybara
|
|
23
23
|
# @return [Capybara::Node::Element] The element clicked
|
24
24
|
#
|
25
25
|
def click_link_or_button(locator = nil, **options)
|
26
|
-
find(:link_or_button, locator, options).click
|
26
|
+
find(:link_or_button, locator, **options).click
|
27
27
|
end
|
28
28
|
alias_method :click_on, :click_link_or_button
|
29
29
|
|
@@ -39,7 +39,7 @@ module Capybara
|
|
39
39
|
#
|
40
40
|
# @return [Capybara::Node::Element] The element clicked
|
41
41
|
def click_link(locator = nil, **options)
|
42
|
-
find(:link, locator, options).click
|
42
|
+
find(:link, locator, **options).click
|
43
43
|
end
|
44
44
|
|
45
45
|
##
|
@@ -55,7 +55,7 @@ module Capybara
|
|
55
55
|
# @param [Hash] options See {Capybara::Node::Finders#find_button}
|
56
56
|
# @return [Capybara::Node::Element] The element clicked
|
57
57
|
def click_button(locator = nil, **options)
|
58
|
-
find(:button, locator, options).click
|
58
|
+
find(:button, locator, **options).click
|
59
59
|
end
|
60
60
|
|
61
61
|
##
|
@@ -88,7 +88,7 @@ module Capybara
|
|
88
88
|
def fill_in(locator = nil, with:, currently_with: nil, fill_options: {}, **find_options)
|
89
89
|
find_options[:with] = currently_with if currently_with
|
90
90
|
find_options[:allow_self] = true if locator.nil?
|
91
|
-
find(:fillable_field, locator, find_options).set(with, fill_options)
|
91
|
+
find(:fillable_field, locator, **find_options).set(with, **fill_options)
|
92
92
|
end
|
93
93
|
|
94
94
|
# @!macro label_click
|
@@ -119,7 +119,7 @@ module Capybara
|
|
119
119
|
#
|
120
120
|
# @return [Capybara::Node::Element] The element chosen or the label clicked
|
121
121
|
def choose(locator = nil, **options)
|
122
|
-
_check_with_label(:radio_button, true, locator, options)
|
122
|
+
_check_with_label(:radio_button, true, locator, **options)
|
123
123
|
end
|
124
124
|
|
125
125
|
##
|
@@ -147,7 +147,7 @@ module Capybara
|
|
147
147
|
#
|
148
148
|
# @return [Capybara::Node::Element] The element checked or the label clicked
|
149
149
|
def check(locator = nil, **options)
|
150
|
-
_check_with_label(:checkbox, true, locator, options)
|
150
|
+
_check_with_label(:checkbox, true, locator, **options)
|
151
151
|
end
|
152
152
|
|
153
153
|
##
|
@@ -175,7 +175,7 @@ module Capybara
|
|
175
175
|
#
|
176
176
|
# @return [Capybara::Node::Element] The element unchecked or the label clicked
|
177
177
|
def uncheck(locator = nil, **options)
|
178
|
-
_check_with_label(:checkbox, false, locator, options)
|
178
|
+
_check_with_label(:checkbox, false, locator, **options)
|
179
179
|
end
|
180
180
|
|
181
181
|
##
|
@@ -205,7 +205,7 @@ module Capybara
|
|
205
205
|
if el.respond_to?(:tag_name) && (el.tag_name == 'input')
|
206
206
|
select_datalist_option(el, value)
|
207
207
|
else
|
208
|
-
el.find(:option, value, options).select_option
|
208
|
+
el.find(:option, value, **options).select_option
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
@@ -229,8 +229,8 @@ module Capybara
|
|
229
229
|
def unselect(value = nil, from: nil, **options)
|
230
230
|
raise ArgumentError, 'The :from option does not take an element' if from.is_a? Capybara::Node::Element
|
231
231
|
|
232
|
-
scope = from ? find(:select, from, options) : self
|
233
|
-
scope.find(:option, value, options).unselect_option
|
232
|
+
scope = from ? find(:select, from, **options) : self
|
233
|
+
scope.find(:option, value, **options).unselect_option
|
234
234
|
end
|
235
235
|
|
236
236
|
##
|
@@ -276,7 +276,9 @@ module Capybara
|
|
276
276
|
# @yield Block whose actions will trigger the system file chooser to be shown
|
277
277
|
# @return [Capybara::Node::Element] The file field element
|
278
278
|
def attach_file(locator = nil, paths, make_visible: nil, **options) # rubocop:disable Style/OptionalArguments
|
279
|
-
|
279
|
+
if locator && block_given?
|
280
|
+
raise ArgumentError, '``#attach_file` does not support passing both a locator and a block'
|
281
|
+
end
|
280
282
|
|
281
283
|
Array(paths).each do |path|
|
282
284
|
raise Capybara::FileNotFound, "cannot attach file, #{path} does not exist" unless File.exist?(path.to_s)
|
@@ -295,10 +297,10 @@ module Capybara
|
|
295
297
|
end
|
296
298
|
# Allow user to update the CSS style of the file input since they are so often hidden on a page
|
297
299
|
if make_visible
|
298
|
-
ff = file_field || find(:file_field, locator, options.merge(visible: :all))
|
300
|
+
ff = file_field || find(:file_field, locator, **options.merge(visible: :all))
|
299
301
|
while_visible(ff, make_visible) { |el| el.set(paths) }
|
300
302
|
else
|
301
|
-
(file_field || find(:file_field, locator, options)).set(paths)
|
303
|
+
(file_field || find(:file_field, locator, **options)).set(paths)
|
302
304
|
end
|
303
305
|
end
|
304
306
|
|
@@ -307,12 +309,12 @@ module Capybara
|
|
307
309
|
def find_select_or_datalist_input(from, options)
|
308
310
|
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
309
311
|
begin
|
310
|
-
find(:select, from, options)
|
312
|
+
find(:select, from, **options)
|
311
313
|
rescue Capybara::ElementNotFound => select_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
312
314
|
raise if %i[selected with_selected multiple].any? { |option| options.key?(option) }
|
313
315
|
|
314
316
|
begin
|
315
|
-
find(:datalist_input, from, options)
|
317
|
+
find(:datalist_input, from, **options)
|
316
318
|
rescue Capybara::ElementNotFound => dlinput_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
317
319
|
raise Capybara::ElementNotFound, "#{select_error.message} and #{dlinput_error.message}"
|
318
320
|
end
|
@@ -338,7 +340,9 @@ module Capybara
|
|
338
340
|
visible_css = { opacity: 1, display: 'block', visibility: 'visible', width: 'auto', height: 'auto' }
|
339
341
|
end
|
340
342
|
_update_style(element, visible_css)
|
341
|
-
|
343
|
+
unless element.visible?
|
344
|
+
raise ExpectationNotMet, 'The style changes in :make_visible did not make the file input visible'
|
345
|
+
end
|
342
346
|
|
343
347
|
begin
|
344
348
|
yield element
|
@@ -355,7 +359,7 @@ module Capybara
|
|
355
359
|
|
356
360
|
def _reset_style(element)
|
357
361
|
element.execute_script(RESET_STYLE_SCRIPT)
|
358
|
-
rescue StandardError # rubocop:disable Lint/
|
362
|
+
rescue StandardError # rubocop:disable Lint/SuppressedException swallow extra errors
|
359
363
|
end
|
360
364
|
|
361
365
|
def _check_with_label(selector, checked, locator,
|
@@ -364,13 +368,13 @@ module Capybara
|
|
364
368
|
|
365
369
|
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
366
370
|
begin
|
367
|
-
el = find(selector, locator, options)
|
371
|
+
el = find(selector, locator, **options)
|
368
372
|
el.set(checked)
|
369
373
|
rescue StandardError => e
|
370
374
|
raise unless allow_label_click && catch_error?(e)
|
371
375
|
|
372
376
|
begin
|
373
|
-
el ||= find(selector, locator, options.merge(visible: :all))
|
377
|
+
el ||= find(selector, locator, **options.merge(visible: :all))
|
374
378
|
el.session.find(:label, for: el, visible: true).click unless el.checked? == checked
|
375
379
|
rescue StandardError # swallow extra errors - raise original
|
376
380
|
raise e
|
@@ -42,7 +42,7 @@ module Capybara
|
|
42
42
|
# @return [Boolean]
|
43
43
|
#
|
44
44
|
def has_title?(title, **options)
|
45
|
-
make_predicate(options) { assert_title(title, options) }
|
45
|
+
make_predicate(options) { assert_title(title, **options) }
|
46
46
|
end
|
47
47
|
|
48
48
|
##
|
@@ -52,13 +52,13 @@ module Capybara
|
|
52
52
|
# @return [Boolean]
|
53
53
|
#
|
54
54
|
def has_no_title?(title, **options)
|
55
|
-
make_predicate(options) { assert_no_title(title, options) }
|
55
|
+
make_predicate(options) { assert_no_title(title, **options) }
|
56
56
|
end
|
57
57
|
|
58
58
|
private
|
59
59
|
|
60
60
|
def _verify_title(title, options)
|
61
|
-
query = Capybara::Queries::TitleQuery.new(title, options)
|
61
|
+
query = Capybara::Queries::TitleQuery.new(title, **options)
|
62
62
|
synchronize(query.wait) { yield(query) }
|
63
63
|
true
|
64
64
|
end
|
@@ -113,10 +113,12 @@ module Capybara
|
|
113
113
|
#
|
114
114
|
# @return [Capybara::Node::Element] The element
|
115
115
|
def set(value, **options)
|
116
|
-
|
116
|
+
if ENV['CAPYBARA_THOROUGH'] && readonly?
|
117
|
+
raise Capybara::ReadOnlyElementError, "Attempt to set readonly element with value: #{value}"
|
118
|
+
end
|
117
119
|
|
118
120
|
options = session_options.default_set_options.to_h.merge(options)
|
119
|
-
synchronize { base.set(value, options) }
|
121
|
+
synchronize { base.set(value, **options) }
|
120
122
|
self
|
121
123
|
end
|
122
124
|
|
@@ -163,8 +165,8 @@ module Capybara
|
|
163
165
|
# offset will be from the element center, otherwise it will be from the top left corner of the element
|
164
166
|
# @return [Capybara::Node::Element] The element
|
165
167
|
def click(*keys, **options)
|
166
|
-
perform_click_action(keys, options) do |k, opts|
|
167
|
-
base.click(k, opts)
|
168
|
+
perform_click_action(keys, **options) do |k, opts|
|
169
|
+
base.click(k, **opts)
|
168
170
|
end
|
169
171
|
end
|
170
172
|
|
@@ -176,8 +178,8 @@ module Capybara
|
|
176
178
|
# @macro click_modifiers
|
177
179
|
# @return [Capybara::Node::Element] The element
|
178
180
|
def right_click(*keys, **options)
|
179
|
-
perform_click_action(keys, options) do |k, opts|
|
180
|
-
base.right_click(k, opts)
|
181
|
+
perform_click_action(keys, **options) do |k, opts|
|
182
|
+
base.right_click(k, **opts)
|
181
183
|
end
|
182
184
|
end
|
183
185
|
|
@@ -189,8 +191,8 @@ module Capybara
|
|
189
191
|
# @macro click_modifiers
|
190
192
|
# @return [Capybara::Node::Element] The element
|
191
193
|
def double_click(*keys, **options)
|
192
|
-
perform_click_action(keys, options) do |k, opts|
|
193
|
-
base.double_click(k, opts)
|
194
|
+
perform_click_action(keys, **options) do |k, opts|
|
195
|
+
base.double_click(k, **opts)
|
194
196
|
end
|
195
197
|
end
|
196
198
|
|
@@ -49,7 +49,7 @@ module Capybara
|
|
49
49
|
#
|
50
50
|
def find(*args, **options, &optional_filter_block)
|
51
51
|
options[:session_options] = session_options
|
52
|
-
synced_resolve Capybara::Queries::SelectorQuery.new(*args, options, &optional_filter_block)
|
52
|
+
synced_resolve Capybara::Queries::SelectorQuery.new(*args, **options, &optional_filter_block)
|
53
53
|
end
|
54
54
|
|
55
55
|
##
|
@@ -72,7 +72,7 @@ module Capybara
|
|
72
72
|
#
|
73
73
|
def ancestor(*args, **options, &optional_filter_block)
|
74
74
|
options[:session_options] = session_options
|
75
|
-
synced_resolve Capybara::Queries::AncestorQuery.new(*args, options, &optional_filter_block)
|
75
|
+
synced_resolve Capybara::Queries::AncestorQuery.new(*args, **options, &optional_filter_block)
|
76
76
|
end
|
77
77
|
|
78
78
|
##
|
@@ -95,7 +95,7 @@ module Capybara
|
|
95
95
|
#
|
96
96
|
def sibling(*args, **options, &optional_filter_block)
|
97
97
|
options[:session_options] = session_options
|
98
|
-
synced_resolve Capybara::Queries::SiblingQuery.new(*args, options, &optional_filter_block)
|
98
|
+
synced_resolve Capybara::Queries::SiblingQuery.new(*args, **options, &optional_filter_block)
|
99
99
|
end
|
100
100
|
|
101
101
|
##
|
@@ -125,7 +125,7 @@ module Capybara
|
|
125
125
|
# @return [Capybara::Node::Element] The found element
|
126
126
|
#
|
127
127
|
def find_field(locator = nil, **options, &optional_filter_block)
|
128
|
-
find(:field, locator, options, &optional_filter_block)
|
128
|
+
find(:field, locator, **options, &optional_filter_block)
|
129
129
|
end
|
130
130
|
|
131
131
|
##
|
@@ -145,7 +145,7 @@ module Capybara
|
|
145
145
|
# @return [Capybara::Node::Element] The found element
|
146
146
|
#
|
147
147
|
def find_link(locator = nil, **options, &optional_filter_block)
|
148
|
-
find(:link, locator, options, &optional_filter_block)
|
148
|
+
find(:link, locator, **options, &optional_filter_block)
|
149
149
|
end
|
150
150
|
|
151
151
|
##
|
@@ -172,7 +172,7 @@ module Capybara
|
|
172
172
|
# @return [Capybara::Node::Element] The found element
|
173
173
|
#
|
174
174
|
def find_button(locator = nil, **options, &optional_filter_block)
|
175
|
-
find(:button, locator, options, &optional_filter_block)
|
175
|
+
find(:button, locator, **options, &optional_filter_block)
|
176
176
|
end
|
177
177
|
|
178
178
|
##
|
@@ -186,7 +186,7 @@ module Capybara
|
|
186
186
|
# @return [Capybara::Node::Element] The found element
|
187
187
|
#
|
188
188
|
def find_by_id(id, **options, &optional_filter_block)
|
189
|
-
find(:id, id, options, &optional_filter_block)
|
189
|
+
find(:id, id, **options, &optional_filter_block)
|
190
190
|
end
|
191
191
|
|
192
192
|
##
|
@@ -245,7 +245,7 @@ module Capybara
|
|
245
245
|
minimum_specified = options_include_minimum?(options)
|
246
246
|
options = { minimum: 1 }.merge(options) unless minimum_specified
|
247
247
|
options[:session_options] = session_options
|
248
|
-
query = Capybara::Queries::SelectorQuery.new(*args, options, &optional_filter_block)
|
248
|
+
query = Capybara::Queries::SelectorQuery.new(*args, **options, &optional_filter_block)
|
249
249
|
result = nil
|
250
250
|
begin
|
251
251
|
synchronize(query.wait) do
|
@@ -278,7 +278,7 @@ module Capybara
|
|
278
278
|
#
|
279
279
|
def first(*args, **options, &optional_filter_block)
|
280
280
|
options = { minimum: 1 }.merge(options) unless options_include_minimum?(options)
|
281
|
-
all(*args, options, &optional_filter_block).first
|
281
|
+
all(*args, **options, &optional_filter_block).first
|
282
282
|
end
|
283
283
|
|
284
284
|
private
|
@@ -292,7 +292,9 @@ module Capybara
|
|
292
292
|
result = query.resolve_for(self)
|
293
293
|
end
|
294
294
|
|
295
|
-
|
295
|
+
if ambiguous?(query, result)
|
296
|
+
raise Capybara::Ambiguous, "Ambiguous match, found #{result.size} elements matching #{query.applied_description}"
|
297
|
+
end
|
296
298
|
raise Capybara::ElementNotFound, "Unable to find #{query.applied_description}" if result.empty?
|
297
299
|
|
298
300
|
result.first
|
@@ -107,7 +107,9 @@ module Capybara
|
|
107
107
|
#
|
108
108
|
def assert_selector(*args, &optional_filter_block)
|
109
109
|
_verify_selector_result(args, optional_filter_block) do |result, query|
|
110
|
-
|
110
|
+
unless result.matches_count? && (result.any? || query.expects_none?)
|
111
|
+
raise Capybara::ExpectationNotMet, result.failure_message
|
112
|
+
end
|
111
113
|
end
|
112
114
|
end
|
113
115
|
|
@@ -121,7 +123,7 @@ module Capybara
|
|
121
123
|
# @raise [Capybara::ExpectationNotMet] If the element doesn't have the specified styles
|
122
124
|
#
|
123
125
|
def assert_matches_style(styles, **options)
|
124
|
-
query_args = _set_query_session_options(styles, options)
|
126
|
+
query_args = _set_query_session_options(styles, **options)
|
125
127
|
query = Capybara::Queries::StyleQuery.new(*query_args)
|
126
128
|
synchronize(query.wait) do
|
127
129
|
raise Capybara::ExpectationNotMet, query.failure_message unless query.resolves_for?(self)
|
@@ -153,7 +155,7 @@ module Capybara
|
|
153
155
|
# @overload assert_all_of_selectors([kind = Capybara.default_selector], *locators, **options)
|
154
156
|
#
|
155
157
|
def assert_all_of_selectors(*args, **options, &optional_filter_block)
|
156
|
-
_verify_multiple(*args, options) do |selector, locator, opts|
|
158
|
+
_verify_multiple(*args, **options) do |selector, locator, opts|
|
157
159
|
assert_selector(selector, locator, opts, &optional_filter_block)
|
158
160
|
end
|
159
161
|
end
|
@@ -174,7 +176,7 @@ module Capybara
|
|
174
176
|
# @overload assert_none_of_selectors([kind = Capybara.default_selector], *locators, **options)
|
175
177
|
#
|
176
178
|
def assert_none_of_selectors(*args, **options, &optional_filter_block)
|
177
|
-
_verify_multiple(*args, options) do |selector, locator, opts|
|
179
|
+
_verify_multiple(*args, **options) do |selector, locator, opts|
|
178
180
|
assert_no_selector(selector, locator, opts, &optional_filter_block)
|
179
181
|
end
|
180
182
|
end
|
@@ -266,7 +268,7 @@ module Capybara
|
|
266
268
|
# @return [Boolean] If the expression exists
|
267
269
|
#
|
268
270
|
def has_xpath?(path, **options, &optional_filter_block)
|
269
|
-
has_selector?(:xpath, path, options, &optional_filter_block)
|
271
|
+
has_selector?(:xpath, path, **options, &optional_filter_block)
|
270
272
|
end
|
271
273
|
|
272
274
|
##
|
@@ -278,7 +280,7 @@ module Capybara
|
|
278
280
|
# @return [Boolean]
|
279
281
|
#
|
280
282
|
def has_no_xpath?(path, **options, &optional_filter_block)
|
281
|
-
has_no_selector?(:xpath, path, options, &optional_filter_block)
|
283
|
+
has_no_selector?(:xpath, path, **options, &optional_filter_block)
|
282
284
|
end
|
283
285
|
|
284
286
|
##
|
@@ -305,7 +307,7 @@ module Capybara
|
|
305
307
|
# @return [Boolean] If the selector exists
|
306
308
|
#
|
307
309
|
def has_css?(path, **options, &optional_filter_block)
|
308
|
-
has_selector?(:css, path, options, &optional_filter_block)
|
310
|
+
has_selector?(:css, path, **options, &optional_filter_block)
|
309
311
|
end
|
310
312
|
|
311
313
|
##
|
@@ -317,7 +319,7 @@ module Capybara
|
|
317
319
|
# @return [Boolean]
|
318
320
|
#
|
319
321
|
def has_no_css?(path, **options, &optional_filter_block)
|
320
|
-
has_no_selector?(:css, path, options, &optional_filter_block)
|
322
|
+
has_no_selector?(:css, path, **options, &optional_filter_block)
|
321
323
|
end
|
322
324
|
|
323
325
|
##
|
@@ -330,7 +332,7 @@ module Capybara
|
|
330
332
|
# @return [Boolean] Whether it exists
|
331
333
|
#
|
332
334
|
def has_link?(locator = nil, **options, &optional_filter_block)
|
333
|
-
has_selector?(:link, locator, options, &optional_filter_block)
|
335
|
+
has_selector?(:link, locator, **options, &optional_filter_block)
|
334
336
|
end
|
335
337
|
|
336
338
|
##
|
@@ -342,7 +344,7 @@ module Capybara
|
|
342
344
|
# @return [Boolean] Whether it doesn't exist
|
343
345
|
#
|
344
346
|
def has_no_link?(locator = nil, **options, &optional_filter_block)
|
345
|
-
has_no_selector?(:link, locator, options, &optional_filter_block)
|
347
|
+
has_no_selector?(:link, locator, **options, &optional_filter_block)
|
346
348
|
end
|
347
349
|
|
348
350
|
##
|
@@ -354,7 +356,7 @@ module Capybara
|
|
354
356
|
# @return [Boolean] Whether it exists
|
355
357
|
#
|
356
358
|
def has_button?(locator = nil, **options, &optional_filter_block)
|
357
|
-
has_selector?(:button, locator, options, &optional_filter_block)
|
359
|
+
has_selector?(:button, locator, **options, &optional_filter_block)
|
358
360
|
end
|
359
361
|
|
360
362
|
##
|
@@ -366,7 +368,7 @@ module Capybara
|
|
366
368
|
# @return [Boolean] Whether it doesn't exist
|
367
369
|
#
|
368
370
|
def has_no_button?(locator = nil, **options, &optional_filter_block)
|
369
|
-
has_no_selector?(:button, locator, options, &optional_filter_block)
|
371
|
+
has_no_selector?(:button, locator, **options, &optional_filter_block)
|
370
372
|
end
|
371
373
|
|
372
374
|
##
|
@@ -392,7 +394,7 @@ module Capybara
|
|
392
394
|
# @return [Boolean] Whether it exists
|
393
395
|
#
|
394
396
|
def has_field?(locator = nil, **options, &optional_filter_block)
|
395
|
-
has_selector?(:field, locator, options, &optional_filter_block)
|
397
|
+
has_selector?(:field, locator, **options, &optional_filter_block)
|
396
398
|
end
|
397
399
|
|
398
400
|
##
|
@@ -406,7 +408,7 @@ module Capybara
|
|
406
408
|
# @return [Boolean] Whether it doesn't exist
|
407
409
|
#
|
408
410
|
def has_no_field?(locator = nil, **options, &optional_filter_block)
|
409
|
-
has_no_selector?(:field, locator, options, &optional_filter_block)
|
411
|
+
has_no_selector?(:field, locator, **options, &optional_filter_block)
|
410
412
|
end
|
411
413
|
|
412
414
|
##
|
@@ -419,7 +421,7 @@ module Capybara
|
|
419
421
|
# @return [Boolean] Whether it exists
|
420
422
|
#
|
421
423
|
def has_checked_field?(locator = nil, **options, &optional_filter_block)
|
422
|
-
has_selector?(:field, locator, options.merge(checked: true), &optional_filter_block)
|
424
|
+
has_selector?(:field, locator, **options.merge(checked: true), &optional_filter_block)
|
423
425
|
end
|
424
426
|
|
425
427
|
##
|
@@ -432,7 +434,7 @@ module Capybara
|
|
432
434
|
# @return [Boolean] Whether it doesn't exist
|
433
435
|
#
|
434
436
|
def has_no_checked_field?(locator = nil, **options, &optional_filter_block)
|
435
|
-
has_no_selector?(:field, locator, options.merge(checked: true), &optional_filter_block)
|
437
|
+
has_no_selector?(:field, locator, **options.merge(checked: true), &optional_filter_block)
|
436
438
|
end
|
437
439
|
|
438
440
|
##
|
@@ -445,7 +447,7 @@ module Capybara
|
|
445
447
|
# @return [Boolean] Whether it exists
|
446
448
|
#
|
447
449
|
def has_unchecked_field?(locator = nil, **options, &optional_filter_block)
|
448
|
-
has_selector?(:field, locator, options.merge(unchecked: true), &optional_filter_block)
|
450
|
+
has_selector?(:field, locator, **options.merge(unchecked: true), &optional_filter_block)
|
449
451
|
end
|
450
452
|
|
451
453
|
##
|
@@ -458,7 +460,7 @@ module Capybara
|
|
458
460
|
# @return [Boolean] Whether it doesn't exist
|
459
461
|
#
|
460
462
|
def has_no_unchecked_field?(locator = nil, **options, &optional_filter_block)
|
461
|
-
has_no_selector?(:field, locator, options.merge(unchecked: true), &optional_filter_block)
|
463
|
+
has_no_selector?(:field, locator, **options.merge(unchecked: true), &optional_filter_block)
|
462
464
|
end
|
463
465
|
|
464
466
|
##
|
@@ -491,7 +493,7 @@ module Capybara
|
|
491
493
|
# @return [Boolean] Whether it exists
|
492
494
|
#
|
493
495
|
def has_select?(locator = nil, **options, &optional_filter_block)
|
494
|
-
has_selector?(:select, locator, options, &optional_filter_block)
|
496
|
+
has_selector?(:select, locator, **options, &optional_filter_block)
|
495
497
|
end
|
496
498
|
|
497
499
|
##
|
@@ -503,7 +505,7 @@ module Capybara
|
|
503
505
|
# @return [Boolean] Whether it doesn't exist
|
504
506
|
#
|
505
507
|
def has_no_select?(locator = nil, **options, &optional_filter_block)
|
506
|
-
has_no_selector?(:select, locator, options, &optional_filter_block)
|
508
|
+
has_no_selector?(:select, locator, **options, &optional_filter_block)
|
507
509
|
end
|
508
510
|
|
509
511
|
##
|
@@ -525,7 +527,7 @@ module Capybara
|
|
525
527
|
# @return [Boolean] Whether it exists
|
526
528
|
#
|
527
529
|
def has_table?(locator = nil, **options, &optional_filter_block)
|
528
|
-
has_selector?(:table, locator, options, &optional_filter_block)
|
530
|
+
has_selector?(:table, locator, **options, &optional_filter_block)
|
529
531
|
end
|
530
532
|
|
531
533
|
##
|
@@ -537,7 +539,7 @@ module Capybara
|
|
537
539
|
# @return [Boolean] Whether it doesn't exist
|
538
540
|
#
|
539
541
|
def has_no_table?(locator = nil, **options, &optional_filter_block)
|
540
|
-
has_no_selector?(:table, locator, options, &optional_filter_block)
|
542
|
+
has_no_selector?(:table, locator, **options, &optional_filter_block)
|
541
543
|
end
|
542
544
|
|
543
545
|
##
|
@@ -595,7 +597,7 @@ module Capybara
|
|
595
597
|
# @return [Boolean]
|
596
598
|
#
|
597
599
|
def matches_xpath?(xpath, **options, &optional_filter_block)
|
598
|
-
matches_selector?(:xpath, xpath, options, &optional_filter_block)
|
600
|
+
matches_selector?(:xpath, xpath, **options, &optional_filter_block)
|
599
601
|
end
|
600
602
|
|
601
603
|
##
|
@@ -606,7 +608,7 @@ module Capybara
|
|
606
608
|
# @return [Boolean]
|
607
609
|
#
|
608
610
|
def matches_css?(css, **options, &optional_filter_block)
|
609
|
-
matches_selector?(:css, css, options, &optional_filter_block)
|
611
|
+
matches_selector?(:css, css, **options, &optional_filter_block)
|
610
612
|
end
|
611
613
|
|
612
614
|
##
|
@@ -629,7 +631,7 @@ module Capybara
|
|
629
631
|
# @return [Boolean]
|
630
632
|
#
|
631
633
|
def not_matches_xpath?(xpath, **options, &optional_filter_block)
|
632
|
-
not_matches_selector?(:xpath, xpath, options, &optional_filter_block)
|
634
|
+
not_matches_selector?(:xpath, xpath, **options, &optional_filter_block)
|
633
635
|
end
|
634
636
|
|
635
637
|
##
|
@@ -640,7 +642,7 @@ module Capybara
|
|
640
642
|
# @return [Boolean]
|
641
643
|
#
|
642
644
|
def not_matches_css?(css, **options, &optional_filter_block)
|
643
|
-
not_matches_selector?(:css, css, options, &optional_filter_block)
|
645
|
+
not_matches_selector?(:css, css, **options, &optional_filter_block)
|
644
646
|
end
|
645
647
|
|
646
648
|
##
|
@@ -671,7 +673,7 @@ module Capybara
|
|
671
673
|
# @return [true]
|
672
674
|
#
|
673
675
|
def assert_text(*args)
|
674
|
-
_verify_text(args) do |count, query|
|
676
|
+
_verify_text(*args) do |count, query|
|
675
677
|
unless query.matches_count?(count) && (count.positive? || query.expects_none?)
|
676
678
|
raise Capybara::ExpectationNotMet, query.failure_message
|
677
679
|
end
|
@@ -687,7 +689,7 @@ module Capybara
|
|
687
689
|
# @return [true]
|
688
690
|
#
|
689
691
|
def assert_no_text(*args)
|
690
|
-
_verify_text(args) do |count, query|
|
692
|
+
_verify_text(*args) do |count, query|
|
691
693
|
if query.matches_count?(count) && (count.positive? || query.expects_none?)
|
692
694
|
raise Capybara::ExpectationNotMet, query.negative_failure_message
|
693
695
|
end
|
@@ -738,7 +740,9 @@ module Capybara
|
|
738
740
|
#
|
739
741
|
def assert_ancestor(*args, &optional_filter_block)
|
740
742
|
_verify_selector_result(args, optional_filter_block, Capybara::Queries::AncestorQuery) do |result, query|
|
741
|
-
|
743
|
+
unless result.matches_count? && (result.any? || query.expects_none?)
|
744
|
+
raise Capybara::ExpectationNotMet, result.failure_message
|
745
|
+
end
|
742
746
|
end
|
743
747
|
end
|
744
748
|
|
@@ -779,7 +783,9 @@ module Capybara
|
|
779
783
|
#
|
780
784
|
def assert_sibling(*args, &optional_filter_block)
|
781
785
|
_verify_selector_result(args, optional_filter_block, Capybara::Queries::SiblingQuery) do |result, query|
|
782
|
-
|
786
|
+
unless result.matches_count? && (result.any? || query.expects_none?)
|
787
|
+
raise Capybara::ExpectationNotMet, result.failure_message
|
788
|
+
end
|
783
789
|
end
|
784
790
|
end
|
785
791
|
|
@@ -843,9 +849,9 @@ module Capybara
|
|
843
849
|
true
|
844
850
|
end
|
845
851
|
|
846
|
-
def _verify_text(
|
847
|
-
|
848
|
-
query = Capybara::Queries::TextQuery.new(
|
852
|
+
def _verify_text(type = nil, expected_text, **query_options) # rubocop:disable Style/OptionalArguments
|
853
|
+
query_options[:session_options] = session_options
|
854
|
+
query = Capybara::Queries::TextQuery.new(type, expected_text, **query_options)
|
849
855
|
synchronize(query.wait) do
|
850
856
|
yield query.resolve_for(self), query
|
851
857
|
end
|