capybara 3.33.0 → 3.34.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +44 -15
  3. data/README.md +0 -2
  4. data/lib/capybara.rb +1 -1
  5. data/lib/capybara/config.rb +4 -6
  6. data/lib/capybara/driver/base.rb +4 -0
  7. data/lib/capybara/helpers.rb +25 -1
  8. data/lib/capybara/minitest.rb +2 -2
  9. data/lib/capybara/minitest/spec.rb +14 -11
  10. data/lib/capybara/node/actions.rb +1 -2
  11. data/lib/capybara/node/element.rb +1 -5
  12. data/lib/capybara/node/finders.rb +7 -6
  13. data/lib/capybara/node/matchers.rb +7 -5
  14. data/lib/capybara/node/simple.rb +5 -1
  15. data/lib/capybara/queries/ancestor_query.rb +1 -1
  16. data/lib/capybara/queries/current_path_query.rb +14 -4
  17. data/lib/capybara/queries/selector_query.rb +8 -9
  18. data/lib/capybara/queries/sibling_query.rb +1 -1
  19. data/lib/capybara/queries/text_query.rb +2 -2
  20. data/lib/capybara/rack_test/browser.rb +7 -3
  21. data/lib/capybara/rack_test/driver.rb +1 -0
  22. data/lib/capybara/rack_test/form.rb +1 -1
  23. data/lib/capybara/rack_test/node.rb +1 -1
  24. data/lib/capybara/registration_container.rb +3 -3
  25. data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
  26. data/lib/capybara/registrations/servers.rb +1 -0
  27. data/lib/capybara/result.rb +3 -7
  28. data/lib/capybara/rspec.rb +2 -0
  29. data/lib/capybara/rspec/matcher_proxies.rb +1 -1
  30. data/lib/capybara/rspec/matchers.rb +7 -6
  31. data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
  32. data/lib/capybara/rspec/matchers/match_style.rb +5 -0
  33. data/lib/capybara/selector/definition.rb +6 -5
  34. data/lib/capybara/selector/definition/button.rb +7 -5
  35. data/lib/capybara/selector/definition/css.rb +1 -1
  36. data/lib/capybara/selector/definition/datalist_input.rb +1 -1
  37. data/lib/capybara/selector/definition/element.rb +2 -1
  38. data/lib/capybara/selector/definition/label.rb +1 -1
  39. data/lib/capybara/selector/definition/select.rb +1 -1
  40. data/lib/capybara/selector/definition/table_row.rb +1 -1
  41. data/lib/capybara/selector/filter_set.rb +2 -2
  42. data/lib/capybara/selector/selector.rb +5 -1
  43. data/lib/capybara/selenium/driver.rb +29 -3
  44. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +3 -3
  45. data/lib/capybara/selenium/driver_specializations/edge_driver.rb +3 -3
  46. data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +1 -1
  47. data/lib/capybara/selenium/extensions/find.rb +3 -3
  48. data/lib/capybara/selenium/extensions/scroll.rb +8 -10
  49. data/lib/capybara/selenium/node.rb +6 -3
  50. data/lib/capybara/selenium/nodes/chrome_node.rb +20 -2
  51. data/lib/capybara/selenium/nodes/safari_node.rb +1 -1
  52. data/lib/capybara/selenium/patches/atoms.rb +4 -4
  53. data/lib/capybara/selenium/patches/logs.rb +4 -4
  54. data/lib/capybara/server/animation_disabler.rb +3 -2
  55. data/lib/capybara/server/middleware.rb +4 -2
  56. data/lib/capybara/session.rb +20 -11
  57. data/lib/capybara/session/matchers.rb +11 -11
  58. data/lib/capybara/spec/public/test.js +6 -1
  59. data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
  60. data/lib/capybara/spec/session/check_spec.rb +6 -0
  61. data/lib/capybara/spec/session/current_url_spec.rb +11 -1
  62. data/lib/capybara/spec/session/has_button_spec.rb +2 -0
  63. data/lib/capybara/spec/session/has_css_spec.rb +2 -1
  64. data/lib/capybara/spec/session/has_current_path_spec.rb +13 -0
  65. data/lib/capybara/spec/session/has_text_spec.rb +0 -11
  66. data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
  67. data/lib/capybara/spec/session/node_spec.rb +22 -2
  68. data/lib/capybara/spec/session/refresh_spec.rb +1 -0
  69. data/lib/capybara/spec/session/save_page_spec.rb +4 -4
  70. data/lib/capybara/spec/spec_helper.rb +11 -12
  71. data/lib/capybara/spec/test_app.rb +8 -3
  72. data/lib/capybara/spec/views/form.erb +18 -0
  73. data/lib/capybara/spec/views/with_animation.erb +8 -0
  74. data/lib/capybara/spec/views/with_js.erb +1 -0
  75. data/lib/capybara/spec/views/with_sortable_js.erb +1 -1
  76. data/lib/capybara/version.rb +1 -1
  77. data/lib/capybara/window.rb +3 -7
  78. data/spec/basic_node_spec.rb +9 -8
  79. data/spec/dsl_spec.rb +1 -1
  80. data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
  81. data/spec/minitest_spec.rb +2 -1
  82. data/spec/rack_test_spec.rb +15 -5
  83. data/spec/rspec/features_spec.rb +3 -1
  84. data/spec/rspec/scenarios_spec.rb +4 -0
  85. data/spec/rspec/shared_spec_matchers.rb +2 -2
  86. data/spec/rspec_spec.rb +4 -0
  87. data/spec/selector_spec.rb +1 -0
  88. data/spec/server_spec.rb +15 -0
  89. data/spec/shared_selenium_session.rb +60 -1
  90. metadata +22 -23
  91. data/lib/capybara/spec/session/source_spec.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab64d9d47c6374c4f203945be70b868fb9e4c48d3fdca087ba4e66498e40b91c
4
- data.tar.gz: 451c97390c148b5b0fad1b06107a4f0de87f17f7b8cef7156fb76ad2ee503f76
3
+ metadata.gz: 73f13e5f3cec460ee010f53337dcbf2d7e692a3b5c557110331d81c75f5f2897
4
+ data.tar.gz: e137144d97fdb0c47a0464c07c4d12a39c36d62cc3c30aaa9201ed5676b2c66f
5
5
  SHA512:
6
- metadata.gz: b0ca3fd8a4535e1df696ddc7f547e066b873d3f4be2b54655fdbb0b6588c5086a87b93500e241e0da031b586c0b6a30cdd8522f209309cf6729c683226bfcf7f
7
- data.tar.gz: d295dcd733856816a1c89810f4d54304a52c251d585afcc62b986a66d63e080e03ddc81bdc46cf51a044e29d2849ccce9bb3cb307a0757746e662394f648a717
6
+ metadata.gz: 8130baab61559c5221035964a776d72ab84a119be31a6b6534de14ca3ebb5ca1cdcd128ad2cd7d004c45d3ff5c7de0103a756cc3fdcf19fb154d874c876883a5
7
+ data.tar.gz: 2379315a8629b50b0681fea69eb603d62d44c058df355f52151e319701d7577e5691fa43283848d0068c769bbd8be0a7890ddac904e7d7aa67e6be0a46261b7d
data/History.md CHANGED
@@ -1,3 +1,31 @@
1
+ # Version 3.34.0
2
+ Release date: 2020-11-26
3
+
4
+ ### Added
5
+
6
+ * Ability to fill in with emoji when using Chrome with selenium driver (Firefox already worked)
7
+ * Current path assetsions/expectations accept optional filter block
8
+ * Animation disabler now specifies `scroll-behavior: auto;` [Nathan Broadbent]
9
+ * :button selector can now find elements by label text [Sean Doyle]
10
+ * `Session#send_keys` to send keys to the current element with focus in drivers that support the
11
+ concept of a current element [Sean Doyle]
12
+
13
+ ### Changed
14
+
15
+ * Text query validates the type parameter to prevent undefined behavior
16
+
17
+ ### Fixed
18
+
19
+ * racktest driver better handles fragments and redirection to urls that include fragments
20
+ * Don't error when attempting to get XPath location of a shadow element
21
+ * Missing `readonly?` added to Node::Simple
22
+ * Selenium version detection when loaded via alternate method [Joel Hawksley]
23
+ * Connection count issue if REQUEST_URI value changed by app [Blake Williams]
24
+ * Maintain URI fragment when redirecting in rack-test driver
25
+ * Text query error message [Wojciech Wnętrzak]
26
+ * Checking a checkbox/radio button with `allow_label_click` now works if there are multiple labels (Issue #2421)
27
+ * `drop` with `Pathname` (Issue #2424)[Máximo Mussini]
28
+
1
29
  # Version 3.33.0
2
30
  Release date: 2020-06-21
3
31
 
@@ -7,11 +35,12 @@ Release date: 2020-06-21
7
35
  * Support for aria-role button when enabled [Seiei Miyagi]
8
36
  * Support for aria-role link when enabled
9
37
  * Support for `validation_message` filter with :field and :fillable_field selectors
38
+ * Deprecation warnings show source location [Koichi ITO]
10
39
 
11
40
  ### Changed
12
41
 
13
42
  * Ruby 2.5.0+ is now required
14
- * Deprecated direct manupulation of the driver and server registries
43
+ * Deprecated direct manipulation of the driver and server registries
15
44
 
16
45
  ### Fixed
17
46
 
@@ -41,7 +70,7 @@ Release date: 2020-03-29
41
70
  ### Added
42
71
 
43
72
  * Support `delay` setting on click with Selenium
44
- * Implement rapid set for values longer thn 30 characters in text fields with Selenium
73
+ * Implement rapid set for values longer than 30 characters in text fields with Selenium
45
74
 
46
75
  ### Fixed
47
76
 
@@ -162,8 +191,8 @@ Release date: 2019-06-27
162
191
 
163
192
  ### Fixed
164
193
 
165
- * Woraround issue with chromedriver 76/77 in W3C mode losing mouse state during legacy drag. Only fixed if
166
- both source and target are simultaenously inside the viewport - Issue #2223
194
+ * Work around issue with chromedriver 76/77 in W3C mode losing mouse state during legacy drag. Only fixed if
195
+ both source and target are simultaneously inside the viewport - Issue #2223
167
196
  * Negative ancestor expectations/predicates were incorrectly checking siblings rather than ancestors
168
197
 
169
198
  # Version 3.24.0
@@ -442,7 +471,7 @@ Release date: 2018-10-23
442
471
 
443
472
  ### Fixed
444
473
 
445
- * Selector `css` expression definiton declared filters now work again
474
+ * Selector `css` expression definition declared filters now work again
446
475
  * Cleaned up warnings [Yuji Yaginuma]
447
476
  * 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
448
477
 
@@ -559,7 +588,7 @@ Release date: 2018-07-19
559
588
 
560
589
  ### Fixed
561
590
 
562
- * Make selenium driver :backspace clear stategy work even if caret location is in middle of field content [Champier Cyril]
591
+ * Make selenium driver :backspace clear strategy work even if caret location is in middle of field content [Champier Cyril]
563
592
  * Selenium issue with fieldset nested in disabled fieldset not being considered disabled
564
593
  * `Session#evaluate_script` and `Element#evaluate_script` now strip leading/trailing whitespace from scripts [Ian Lesperance]
565
594
 
@@ -658,7 +687,7 @@ Release date: 2018-04-13
658
687
  ### Fixes
659
688
 
660
689
  * Fix expression filter descriptions in some selector failure messages
661
- * Fix compounding of negated matechers - Issue #2010
690
+ * Fix compounding of negated matchers - Issue #2010
662
691
 
663
692
  # Version 3.0.1
664
693
  Release date: 2018-04-06
@@ -932,7 +961,7 @@ Release date: 2016-12-05
932
961
  * Options for clearing session/local storage on reset added to the Selenium driver
933
962
  * Window size changes wait for the size to stabilize
934
963
  * Defined return value for most actions
935
- * Ignore specific error when qutting selenium driver instance - Issue #1773 [Dylan Reichstadt, Thomas Walpole]
964
+ * Ignore specific error when quitting selenium driver instance - Issue #1773 [Dylan Reichstadt, Thomas Walpole]
936
965
  * Warn on selenium unknown errors rather than raising when quitting driver [Adam Pohorecki, Thomas Walpole]
937
966
  * Capybara::Result#each now returns an `Enumerator` when called without a block - Issue #1777 [Thomas Walpole]
938
967
 
@@ -994,7 +1023,7 @@ Release date: 2016-09-19
994
1023
 
995
1024
  ### Fixed
996
1025
 
997
- * Issue with rack-test driver and obselete mime-types when using `#attach_file` - Issue #1756 [Thomas Walpole]
1026
+ * Issue with rack-test driver and obsolete mime-types when using `#attach_file` - Issue #1756 [Thomas Walpole]
998
1027
 
999
1028
  ### Added
1000
1029
 
@@ -1061,7 +1090,7 @@ Release date: 2016-04-07
1061
1090
 
1062
1091
  ### Added
1063
1092
 
1064
- * Capybara now waits for requests to Capybaras server to complete while restting the session [John Hawthorn, Thomas Walpole]
1093
+ * Capybara now waits for requests to Capybaras server to complete while resetting the session [John Hawthorn, Thomas Walpole]
1065
1094
  * Capybara.reuse_server option to allow disabling of sharing server instance between sessions [Thomas Walpole]
1066
1095
  * :multiple filter added to relevant selectors [Thomas Walpole]
1067
1096
  * Provided server registrations for :webrick and :puma. Capybara.server = :puma for testing with Rails 5 [Thomas Walpole]
@@ -1075,7 +1104,7 @@ Release date: 2016-04-07
1075
1104
 
1076
1105
  # Version 2.6.2
1077
1106
 
1078
- Relase date: 2016-01-27
1107
+ Release date: 2016-01-27
1079
1108
 
1080
1109
  ### Fixed
1081
1110
 
@@ -1621,8 +1650,8 @@ Release date: 2011-06-14
1621
1650
  * Rack::Test driver honours maxlength on input fields [Guilherme Carvalho]
1622
1651
  * Rack::Test now works as expected with domains and subdomains [Jonas Nicklas]
1623
1652
  * Session is reset more thoroughly between tests. [Jonas Nicklas]
1624
- * Raise error when uploading non-existant file [Jonas Nicklas]
1625
- * Rack reponse body should respond to #each [Piotr Sarnacki]
1653
+ * Raise error when uploading non-existent file [Jonas Nicklas]
1654
+ * Rack response body should respond to #each [Piotr Sarnacki]
1626
1655
  * Deprecation warnings with selenium webdriver 0.2.0 [Aaron Gibraltar]
1627
1656
  * Selenium Chrome no longer YELLS tagname [Carl Jackson & David W. Frank]
1628
1657
  * Capybara no longer strips encoding before sending to Rack [Jonas Nicklas]
@@ -1764,7 +1793,7 @@ Release date: 2010-05-12
1764
1793
 
1765
1794
  Release date: 2010-04-09
1766
1795
 
1767
- This is a drop in compatible maintainance release. It's mostly
1796
+ This is a drop in compatible maintenance release. It's mostly
1768
1797
  important for driver authors.
1769
1798
 
1770
1799
  ### Added
@@ -1783,7 +1812,7 @@ important for driver authors.
1783
1812
 
1784
1813
  Release date: 2010-03-22
1785
1814
 
1786
- This is a maintainance release with minor bug fixes, should be
1815
+ This is a maintenance release with minor bug fixes, should be
1787
1816
  drop in compatible.
1788
1817
 
1789
1818
  ### Added
data/README.md CHANGED
@@ -7,8 +7,6 @@
7
7
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
8
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=capybara&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=capybara&package-manager=bundler&version-scheme=semver)
9
9
 
10
- **Note** You are viewing the README for the 3.33.x release 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
@@ -484,7 +484,7 @@ module Capybara
484
484
  require 'capybara/rack_test/node'
485
485
  require 'capybara/rack_test/form'
486
486
  require 'capybara/rack_test/browser'
487
- require 'capybara/rack_test/css_handlers.rb'
487
+ require 'capybara/rack_test/css_handlers'
488
488
 
489
489
  require 'capybara/selenium/node'
490
490
  require 'capybara/selenium/driver'
@@ -9,11 +9,9 @@ module Capybara
9
9
 
10
10
  OPTIONS = %i[app reuse_server threadsafe server default_driver javascript_driver allow_gumbo].freeze
11
11
 
12
- attr_accessor :app
13
- attr_reader :reuse_server, :threadsafe
14
- attr_reader :session_options
12
+ attr_accessor :app, :allow_gumbo
13
+ attr_reader :reuse_server, :threadsafe, :session_options
15
14
  attr_writer :default_driver, :javascript_driver
16
- attr_accessor :allow_gumbo
17
15
 
18
16
  SessionConfig::OPTIONS.each do |method|
19
17
  def_delegators :session_options, method, "#{method}="
@@ -83,10 +81,10 @@ module Capybara
83
81
  @javascript_driver || :selenium
84
82
  end
85
83
 
86
- def deprecate(method, alternate_method, once = false)
84
+ def deprecate(method, alternate_method, once: false)
87
85
  @deprecation_notified ||= {}
88
86
  unless once && @deprecation_notified[method]
89
- warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead"
87
+ Capybara::Helpers.warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead: #{Capybara::Helpers.filter_backtrace(caller)}"
90
88
  end
91
89
  @deprecation_notified[method] = true
92
90
  end
@@ -59,6 +59,10 @@ class Capybara::Driver::Base
59
59
  raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#status_code'
60
60
  end
61
61
 
62
+ def send_keys(*)
63
+ raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#send_keys'
64
+ end
65
+
62
66
  ##
63
67
  #
64
68
  # @param frame [Capybara::Node::Element, :parent, :top] The iframe element to switch to
@@ -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,6 +70,30 @@ module Capybara
70
70
  count == 1 ? singular : plural
71
71
  end
72
72
 
73
+ def filter_backtrace(trace)
74
+ return 'No backtrace' unless trace
75
+
76
+ filter = %r{lib/capybara/|lib/rspec/|lib/minitest/}
77
+ new_trace = trace.take_while { |line| line !~ filter }
78
+ new_trace = trace.reject { |line| line =~ 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
+ return Kernel.warn(message, uplevel: uplevel) if RUBY_VERSION >= '2.6'
86
+
87
+ # TODO: Remove when we drop support for Ruby 2.5
88
+ # Workaround for emulating `warn '...', uplevel: n` in Ruby 2.5 or lower.
89
+ if (match = /^(?<file>.+?):(?<line>\d+)(?::in `.*')?/.match(caller[uplevel]))
90
+ location = [match[:file], match[:line]].join(':')
91
+ Kernel.warn "#{location}: #{message}"
92
+ else
93
+ Kernel.warn message
94
+ end
95
+ end
96
+
73
97
  if defined?(Process::CLOCK_MONOTONIC)
74
98
  def monotonic_time; Process.clock_gettime Process::CLOCK_MONOTONIC; end
75
99
  else
@@ -50,10 +50,10 @@ module Capybara
50
50
 
51
51
  %w[text no_text title no_title current_path no_current_path].each do |assertion_name|
52
52
  class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
53
- def assert_#{assertion_name}(*args, **kwargs)
53
+ def assert_#{assertion_name}(*args, **kwargs, &optional_filter_block)
54
54
  self.assertions +=1
55
55
  subject, args = determine_subject(args)
56
- subject.assert_#{assertion_name}(*args, **kwargs)
56
+ subject.assert_#{assertion_name}(*args, **kwargs, &optional_filter_block)
57
57
  rescue Capybara::ExpectationNotMet => e
58
58
  raise ::Minitest::Assertion, e.message
59
59
  end
@@ -209,13 +209,15 @@ module Capybara
209
209
  # @!method wont_have_xpath
210
210
  # See {Capybara::Node::Matchers#has_no_xpath?}
211
211
 
212
- %w[text content title current_path].each do |assertion|
213
- infect_an_assertion "assert_#{assertion}", "must_have_#{assertion}", :reverse
214
- infect_an_assertion "refute_#{assertion}", "wont_have_#{assertion}", :reverse
215
- end
212
+ # This currently doesn't work for Ruby 2.8 due to Minitest not forwarding keyword args separately
213
+ # %w[text content title current_path].each do |assertion|
214
+ # infect_an_assertion "assert_#{assertion}", "must_have_#{assertion}", :reverse
215
+ # infect_an_assertion "refute_#{assertion}", "wont_have_#{assertion}", :reverse
216
+ # end
216
217
 
217
218
  # rubocop:disable Style/MultilineBlockChain
218
- (%w[selector xpath css link button field select table checked_field unchecked_field
219
+ (%w[text content title current_path
220
+ selector xpath css link button field select table checked_field unchecked_field
219
221
  ancestor sibling].flat_map do |assertion|
220
222
  [%W[assert_#{assertion} must_have_#{assertion}],
221
223
  %W[refute_#{assertion} wont_have_#{assertion}]]
@@ -228,14 +230,15 @@ module Capybara
228
230
  %W[refute_matches_#{assertion} wont_match_#{assertion}]]
229
231
  end).each do |(meth, new_name)|
230
232
  class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
231
- def #{new_name} *args, &block
232
- ::Minitest::Expectation.new(self, ::Minitest::Spec.current).#{new_name}(*args, &block)
233
+ def #{new_name} *args, **kw_args, &block
234
+ ::Minitest::Expectation.new(self, ::Minitest::Spec.current).#{new_name}(*args, **kw_args, &block)
233
235
  end
234
236
  ASSERTION
235
237
 
236
238
  ::Minitest::Expectation.class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
237
- def #{new_name} *args, &block
238
- ctx.#{meth}(target, *args, &block)
239
+ def #{new_name} *args, **kw_args, &block
240
+ raise "Calling ##{new_name} outside of test." unless ctx
241
+ ctx.#{meth}(target, *args, **kw_args, &block)
239
242
  end
240
243
  ASSERTION
241
244
  end
@@ -243,9 +246,9 @@ module Capybara
243
246
 
244
247
  ##
245
248
  # @deprecated
246
- def must_have_style(*args, &block)
249
+ def must_have_style(*args, **kw_args, &block)
247
250
  warn 'must_have_style is deprecated, please use must_match_style'
248
- must_match_style(*args, &block)
251
+ must_match_style(*args, **kw_args, &block)
249
252
  end
250
253
  end
251
254
  end
@@ -363,7 +363,6 @@ module Capybara
363
363
  def _check_with_label(selector, checked, locator,
364
364
  allow_label_click: session_options.automatic_label_click, **options)
365
365
  options[:allow_self] = true if locator.nil?
366
-
367
366
  synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
368
367
  el = find(selector, locator, **options)
369
368
  el.set(checked)
@@ -372,7 +371,7 @@ module Capybara
372
371
 
373
372
  begin
374
373
  el ||= find(selector, locator, **options.merge(visible: :all))
375
- el.session.find(:label, for: el, visible: true).click unless el.checked? == checked
374
+ el.session.find(:label, for: el, visible: true, match: :first).click unless el.checked? == checked
376
375
  rescue StandardError # swallow extra errors - raise original
377
376
  raise e
378
377
  end
@@ -435,11 +435,7 @@ module Capybara
435
435
  #
436
436
  # @return [Capybara::Node::Element] The element
437
437
  def drop(*args)
438
- options = args.map do |arg|
439
- return arg.to_path if arg.respond_to?(:to_path)
440
-
441
- arg
442
- end
438
+ options = args.map { |arg| arg.respond_to?(:to_path) ? arg.to_path : arg }
443
439
  synchronize { base.drop(*options) }
444
440
  self
445
441
  end
@@ -24,12 +24,13 @@ module Capybara
24
24
  # @option options [Boolean] normalize_ws
25
25
  # Whether the `text`/`exact_text` options are compared against elment text with whitespace normalized or as returned by the driver.
26
26
  # Defaults to {Capybara.configure default_normalize_ws}.
27
- # @option options [Boolean, Symbol] visible Only find elements with the specified visibility:
28
- # * true - only finds visible elements.
29
- # * false - finds invisible _and_ visible elements.
30
- # * :all - same as false; finds visible and invisible elements.
31
- # * :hidden - only finds invisible elements.
32
- # * :visible - same as true; only finds visible elements.
27
+ # @option options [Boolean, Symbol] visible
28
+ # Only find elements with the specified visibility. Defaults to behavior indicated by {Capybara.configure ignore_hidden_elements}.
29
+ # * true - only finds visible elements.
30
+ # * false - finds invisible _and_ visible elements.
31
+ # * :all - same as false; finds visible and invisible elements.
32
+ # * :hidden - only finds invisible elements.
33
+ # * :visible - same as true; only finds visible elements.
33
34
  # @option options [Boolean] obscured Only find elements with the specified obscured state:
34
35
  # * true - only find elements whose centerpoint is not in the viewport or is obscured by another non-descendant element.
35
36
  # * false - only find elements whose centerpoint is in the viewport and is not obscured by other non-descendant elements.
@@ -60,15 +60,16 @@ module Capybara
60
60
  # @param styles [Hash]
61
61
  # @return [Boolean] If the styles match
62
62
  #
63
- def matches_style?(styles, **options)
63
+ def matches_style?(styles = nil, **options)
64
+ styles, options = options, {} if styles.nil?
64
65
  make_predicate(options) { assert_matches_style(styles, **options) }
65
66
  end
66
67
 
67
68
  ##
68
69
  # @deprecated Use {#matches_style?} instead.
69
70
  #
70
- def has_style?(styles, **options)
71
- warn 'DEPRECATED: has_style? is deprecated, please use matches_style?'
71
+ def has_style?(styles = nil, **options)
72
+ Capybara::Helpers.warn "DEPRECATED: has_style? is deprecated, please use matches_style? : #{Capybara::Helpers.filter_backtrace(caller)}"
72
73
  matches_style?(styles, **options)
73
74
  end
74
75
 
@@ -122,7 +123,8 @@ module Capybara
122
123
  # @param styles [Hash]
123
124
  # @raise [Capybara::ExpectationNotMet] If the element doesn't have the specified styles
124
125
  #
125
- def assert_matches_style(styles, **options)
126
+ def assert_matches_style(styles = nil, **options)
127
+ styles, options = options, {} if styles.nil?
126
128
  query_args, query_opts = _set_query_session_options(styles, options)
127
129
  query = Capybara::Queries::StyleQuery.new(*query_args, **query_opts)
128
130
  synchronize(query.wait) do
@@ -134,7 +136,7 @@ module Capybara
134
136
  ##
135
137
  # @deprecated Use {#assert_matches_style} instead.
136
138
  #
137
- def assert_style(styles, **options)
139
+ def assert_style(styles = nil, **options)
138
140
  warn 'assert_style is deprecated, please use assert_matches_style instead'
139
141
  assert_matches_style(styles, **options)
140
142
  end
@@ -100,7 +100,7 @@ module Capybara
100
100
  # @param [Boolean] check_ancestors Whether to inherit visibility from ancestors
101
101
  # @return [Boolean] Whether the element is visible
102
102
  #
103
- def visible?(check_ancestors = true)
103
+ def visible?(check_ancestors = true) # rubocop:disable Style/OptionalBooleanParameter
104
104
  return false if (tag_name == 'input') && (native[:type] == 'hidden')
105
105
  return false if tag_name == 'template'
106
106
 
@@ -148,6 +148,10 @@ module Capybara
148
148
  native.has_attribute?('multiple')
149
149
  end
150
150
 
151
+ def readonly?
152
+ native.has_attribute?('readonly')
153
+ end
154
+
151
155
  def synchronize(_seconds = nil)
152
156
  yield # simple nodes don't need to wait
153
157
  end
@@ -16,7 +16,7 @@ module Capybara
16
16
  end
17
17
  end
18
18
 
19
- def description(applied = false)
19
+ def description(applied = false) # rubocop:disable Style/OptionalBooleanParameter
20
20
  child_query = @child_node&.instance_variable_get(:@query)
21
21
  desc = super
22
22
  desc += " that is an ancestor of #{child_query.description}" if child_query