capybara 3.30.0 → 3.35.3
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 +153 -13
- data/README.md +9 -4
- data/lib/capybara.rb +18 -8
- data/lib/capybara/config.rb +4 -6
- data/lib/capybara/cucumber.rb +1 -1
- data/lib/capybara/driver/base.rb +4 -0
- data/lib/capybara/dsl.rb +10 -2
- data/lib/capybara/helpers.rb +25 -1
- data/lib/capybara/minitest.rb +232 -144
- data/lib/capybara/minitest/spec.rb +156 -97
- data/lib/capybara/node/actions.rb +16 -21
- data/lib/capybara/node/base.rb +6 -6
- data/lib/capybara/node/element.rb +14 -13
- data/lib/capybara/node/finders.rb +12 -7
- data/lib/capybara/node/matchers.rb +36 -27
- data/lib/capybara/node/simple.rb +6 -2
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/base_query.rb +2 -1
- data/lib/capybara/queries/current_path_query.rb +14 -4
- data/lib/capybara/queries/selector_query.rb +40 -18
- data/lib/capybara/queries/sibling_query.rb +1 -1
- data/lib/capybara/queries/style_query.rb +1 -1
- data/lib/capybara/queries/text_query.rb +7 -1
- data/lib/capybara/rack_test/browser.rb +9 -3
- data/lib/capybara/rack_test/driver.rb +1 -0
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/rack_test/node.rb +35 -10
- data/lib/capybara/registration_container.rb +44 -0
- data/lib/capybara/registrations/drivers.rb +18 -12
- data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
- data/lib/capybara/registrations/servers.rb +3 -2
- data/lib/capybara/result.rb +35 -15
- data/lib/capybara/rspec.rb +2 -0
- data/lib/capybara/rspec/matcher_proxies.rb +5 -5
- data/lib/capybara/rspec/matchers.rb +33 -32
- data/lib/capybara/rspec/matchers/base.rb +12 -6
- data/lib/capybara/rspec/matchers/count_sugar.rb +2 -1
- data/lib/capybara/rspec/matchers/have_ancestor.rb +4 -3
- data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
- data/lib/capybara/rspec/matchers/have_selector.rb +15 -7
- data/lib/capybara/rspec/matchers/have_sibling.rb +3 -3
- data/lib/capybara/rspec/matchers/have_text.rb +3 -3
- data/lib/capybara/rspec/matchers/have_title.rb +2 -2
- data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
- data/lib/capybara/rspec/matchers/match_style.rb +7 -2
- data/lib/capybara/rspec/matchers/spatial_sugar.rb +2 -1
- data/lib/capybara/selector.rb +14 -3
- data/lib/capybara/selector/builders/css_builder.rb +1 -1
- data/lib/capybara/selector/builders/xpath_builder.rb +3 -1
- data/lib/capybara/selector/definition.rb +11 -9
- data/lib/capybara/selector/definition/button.rb +26 -14
- data/lib/capybara/selector/definition/css.rb +1 -1
- data/lib/capybara/selector/definition/datalist_input.rb +1 -1
- data/lib/capybara/selector/definition/element.rb +2 -1
- data/lib/capybara/selector/definition/fillable_field.rb +1 -1
- data/lib/capybara/selector/definition/label.rb +2 -2
- data/lib/capybara/selector/definition/link.rb +8 -0
- data/lib/capybara/selector/definition/select.rb +32 -13
- data/lib/capybara/selector/definition/table.rb +1 -1
- data/lib/capybara/selector/definition/table_row.rb +2 -2
- data/lib/capybara/selector/filter_set.rb +2 -2
- data/lib/capybara/selector/selector.rb +9 -1
- data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -1
- data/lib/capybara/selenium/atoms/src/getAttribute.js +1 -1
- data/lib/capybara/selenium/atoms/src/isDisplayed.js +1 -1
- data/lib/capybara/selenium/driver.rb +52 -7
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +10 -12
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +9 -11
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +3 -3
- data/lib/capybara/selenium/extensions/find.rb +4 -4
- data/lib/capybara/selenium/extensions/html5_drag.rb +24 -8
- data/lib/capybara/selenium/extensions/scroll.rb +8 -10
- data/lib/capybara/selenium/logger_suppressor.rb +8 -2
- data/lib/capybara/selenium/node.rb +96 -16
- data/lib/capybara/selenium/nodes/chrome_node.rb +27 -16
- data/lib/capybara/selenium/nodes/edge_node.rb +1 -1
- data/lib/capybara/selenium/nodes/firefox_node.rb +9 -4
- data/lib/capybara/selenium/nodes/safari_node.rb +1 -1
- data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
- data/lib/capybara/selenium/patches/atoms.rb +4 -4
- data/lib/capybara/selenium/patches/logs.rb +7 -9
- data/lib/capybara/server/animation_disabler.rb +8 -3
- data/lib/capybara/server/middleware.rb +4 -2
- data/lib/capybara/session.rb +53 -29
- data/lib/capybara/session/config.rb +3 -1
- data/lib/capybara/session/matchers.rb +11 -11
- data/lib/capybara/spec/public/test.js +64 -7
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
- data/lib/capybara/spec/session/all_spec.rb +45 -5
- data/lib/capybara/spec/session/assert_text_spec.rb +5 -5
- data/lib/capybara/spec/session/check_spec.rb +6 -0
- data/lib/capybara/spec/session/click_button_spec.rb +11 -0
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +9 -0
- data/lib/capybara/spec/session/current_url_spec.rb +11 -1
- data/lib/capybara/spec/session/fill_in_spec.rb +29 -0
- data/lib/capybara/spec/session/find_spec.rb +11 -8
- data/lib/capybara/spec/session/has_button_spec.rb +51 -0
- data/lib/capybara/spec/session/has_css_spec.rb +14 -10
- data/lib/capybara/spec/session/has_current_path_spec.rb +15 -2
- data/lib/capybara/spec/session/has_field_spec.rb +16 -0
- data/lib/capybara/spec/session/has_select_spec.rb +32 -4
- data/lib/capybara/spec/session/has_selector_spec.rb +4 -4
- data/lib/capybara/spec/session/has_text_spec.rb +5 -12
- data/lib/capybara/spec/session/html_spec.rb +1 -1
- data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
- data/lib/capybara/spec/session/node_spec.rb +169 -33
- data/lib/capybara/spec/session/refresh_spec.rb +2 -1
- data/lib/capybara/spec/session/save_page_spec.rb +4 -4
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_spec.rb +8 -8
- data/lib/capybara/spec/session/window/windows_spec.rb +1 -1
- data/lib/capybara/spec/spec_helper.rb +13 -14
- data/lib/capybara/spec/test_app.rb +23 -21
- data/lib/capybara/spec/views/form.erb +36 -3
- data/lib/capybara/spec/views/with_animation.erb +8 -0
- data/lib/capybara/spec/views/with_dragula.erb +3 -1
- data/lib/capybara/spec/views/with_html.erb +2 -2
- data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
- data/lib/capybara/spec/views/with_js.erb +3 -0
- data/lib/capybara/spec/views/with_sortable_js.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +3 -7
- data/spec/basic_node_spec.rb +9 -8
- data/spec/capybara_spec.rb +1 -1
- data/spec/dsl_spec.rb +14 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
- data/spec/minitest_spec.rb +3 -2
- data/spec/rack_test_spec.rb +28 -6
- data/spec/regexp_dissassembler_spec.rb +0 -4
- data/spec/result_spec.rb +40 -29
- data/spec/rspec/features_spec.rb +3 -1
- data/spec/rspec/scenarios_spec.rb +4 -0
- data/spec/rspec/shared_spec_matchers.rb +63 -51
- data/spec/rspec_spec.rb +4 -0
- data/spec/selector_spec.rb +17 -2
- data/spec/selenium_spec_chrome.rb +45 -21
- data/spec/selenium_spec_chrome_remote.rb +7 -1
- data/spec/selenium_spec_firefox.rb +15 -13
- data/spec/server_spec.rb +60 -49
- data/spec/shared_selenium_node.rb +18 -0
- data/spec/shared_selenium_session.rb +98 -7
- data/spec/spec_helper.rb +1 -1
- metadata +50 -14
- data/lib/capybara/spec/session/source_spec.rb +0 -0
|
@@ -5,192 +5,251 @@ require 'minitest/spec'
|
|
|
5
5
|
module Capybara
|
|
6
6
|
module Minitest
|
|
7
7
|
module Expectations
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
##
|
|
9
|
+
# Expectation that there is an ancestor
|
|
10
|
+
#
|
|
11
|
+
# @!method must_have_ancestor
|
|
12
|
+
# See {Capybara::Node::Matchers#has_ancestor?}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
end + [%w[assert_all_of_selectors must_have_all_of_selectors],
|
|
19
|
-
%w[assert_none_of_selectors must_have_none_of_selectors],
|
|
20
|
-
%w[assert_any_of_selectors must_have_any_of_selectors],
|
|
21
|
-
%w[assert_matches_style must_match_style]] +
|
|
22
|
-
%w[selector xpath css].flat_map do |assertion|
|
|
23
|
-
[%W[assert_matches_#{assertion} must_match_#{assertion}],
|
|
24
|
-
%W[refute_matches_#{assertion} wont_match_#{assertion}]]
|
|
25
|
-
end).each do |(meth, new_name)|
|
|
26
|
-
class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
|
|
27
|
-
def #{new_name} *args, &block
|
|
28
|
-
::Minitest::Expectation.new(self, ::Minitest::Spec.current).#{new_name}(*args, &block)
|
|
29
|
-
end
|
|
30
|
-
ASSERTION
|
|
14
|
+
##
|
|
15
|
+
# Expectation that there is button
|
|
16
|
+
#
|
|
17
|
+
# @!method must_have_button
|
|
18
|
+
# See {Capybara::Node::Matchers#has_button?}
|
|
31
19
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
# rubocop:enable Style/MultilineBlockChain
|
|
20
|
+
##
|
|
21
|
+
# Expectation that there is no button
|
|
22
|
+
#
|
|
23
|
+
# @!method wont_have_button
|
|
24
|
+
# See {Capybara::Node::Matchers#has_no_button?}
|
|
39
25
|
|
|
40
26
|
##
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
end
|
|
27
|
+
# Expectation that there is checked_field
|
|
28
|
+
#
|
|
29
|
+
# @!method must_have_checked_field
|
|
30
|
+
# See {Capybara::Node::Matchers#has_checked_field?}
|
|
46
31
|
|
|
47
32
|
##
|
|
48
|
-
# Expectation that there is
|
|
33
|
+
# Expectation that there is no checked_field
|
|
49
34
|
#
|
|
50
|
-
# @!method
|
|
51
|
-
#
|
|
35
|
+
# @!method wont_have_checked_field
|
|
36
|
+
# See {Capybara::Node::Matchers#has_no_checked_field?}
|
|
52
37
|
|
|
53
38
|
##
|
|
54
|
-
# Expectation that there is
|
|
39
|
+
# Expectation that there is unchecked_field
|
|
55
40
|
#
|
|
56
|
-
# @!method
|
|
57
|
-
#
|
|
41
|
+
# @!method must_have_unchecked_field
|
|
42
|
+
# See {Capybara::Node::Matchers#has_unchecked_field?}
|
|
58
43
|
|
|
59
44
|
##
|
|
60
|
-
# Expectation that there is
|
|
45
|
+
# Expectation that there is no unchecked_field
|
|
61
46
|
#
|
|
62
|
-
# @!method
|
|
63
|
-
#
|
|
47
|
+
# @!method wont_have_unchecked_field
|
|
48
|
+
# See {Capybara::Node::Matchers#has_no_unchecked_field?}
|
|
64
49
|
|
|
65
50
|
##
|
|
66
|
-
# Expectation that
|
|
51
|
+
# Expectation that page content does match
|
|
67
52
|
#
|
|
68
|
-
# @!method
|
|
69
|
-
#
|
|
53
|
+
# @!method must_have_content
|
|
54
|
+
# See {Capybara::Node::Matchers#has_content?}
|
|
70
55
|
|
|
71
56
|
##
|
|
72
|
-
# Expectation that
|
|
57
|
+
# Expectation that page content does not match
|
|
73
58
|
#
|
|
74
|
-
# @!method
|
|
75
|
-
#
|
|
59
|
+
# @!method wont_have_content
|
|
60
|
+
# See {Capybara::Node::Matchers#has_no_content?}
|
|
76
61
|
|
|
77
62
|
##
|
|
78
|
-
# Expectation that there is
|
|
63
|
+
# Expectation that there is css
|
|
79
64
|
#
|
|
80
|
-
# @!method
|
|
81
|
-
#
|
|
65
|
+
# @!method must_have_css
|
|
66
|
+
# See {Capybara::Node::Matchers#has_css?}
|
|
82
67
|
|
|
83
68
|
##
|
|
84
|
-
# Expectation that there is
|
|
69
|
+
# Expectation that there is no css
|
|
85
70
|
#
|
|
86
|
-
# @!method
|
|
87
|
-
#
|
|
71
|
+
# @!method wont_have_css
|
|
72
|
+
# See {Capybara::Node::Matchers#has_no_css?}
|
|
88
73
|
|
|
89
74
|
##
|
|
90
|
-
# Expectation that
|
|
75
|
+
# Expectation that current path matches
|
|
91
76
|
#
|
|
92
|
-
# @!method
|
|
93
|
-
#
|
|
77
|
+
# @!method must_have_current_path
|
|
78
|
+
# See {Capybara::SessionMatchers#has_current_path?}
|
|
79
|
+
|
|
80
|
+
##
|
|
81
|
+
# Expectation that current page does not match
|
|
82
|
+
#
|
|
83
|
+
# @!method wont_have_current_path
|
|
84
|
+
# See {Capybara::SessionMatchers#has_no_current_path?}
|
|
94
85
|
|
|
95
86
|
##
|
|
96
87
|
# Expectation that there is field
|
|
97
88
|
#
|
|
98
89
|
# @!method must_have_field
|
|
99
|
-
#
|
|
90
|
+
# See {Capybara::Node::Matchers#has_field?}
|
|
100
91
|
|
|
101
92
|
##
|
|
102
93
|
# Expectation that there is no field
|
|
103
94
|
#
|
|
104
95
|
# @!method wont_have_field
|
|
105
|
-
#
|
|
96
|
+
# See {Capybara::Node::Matchers#has_no_field?}
|
|
106
97
|
|
|
107
98
|
##
|
|
108
|
-
# Expectation that there is
|
|
99
|
+
# Expectation that there is link
|
|
109
100
|
#
|
|
110
|
-
# @!method
|
|
111
|
-
#
|
|
101
|
+
# @!method must_have_link
|
|
102
|
+
# See {Capybara::Node::Matchers#has_link?}
|
|
112
103
|
|
|
113
104
|
##
|
|
114
|
-
# Expectation that there is no
|
|
105
|
+
# Expectation that there is no link
|
|
115
106
|
#
|
|
116
|
-
# @!method
|
|
107
|
+
# @!method wont_have_link
|
|
108
|
+
# See {Capybara::Node::Matchers#has_no_link?}
|
|
117
109
|
|
|
118
110
|
##
|
|
119
|
-
# Expectation that
|
|
111
|
+
# Expectation that page text does match
|
|
120
112
|
#
|
|
121
|
-
# @!method
|
|
122
|
-
#
|
|
113
|
+
# @!method must_have_text
|
|
114
|
+
# See {Capybara::Node::Matchers#has_text?}
|
|
123
115
|
|
|
124
116
|
##
|
|
125
|
-
# Expectation that
|
|
117
|
+
# Expectation that page text does not match
|
|
126
118
|
#
|
|
127
|
-
# @!method
|
|
119
|
+
# @!method wont_have_text
|
|
120
|
+
# See {Capybara::Node::Matchers#has_no_text?}
|
|
121
|
+
|
|
122
|
+
##
|
|
123
|
+
# Expectation that page title does match
|
|
124
|
+
#
|
|
125
|
+
# @!method must_have_title
|
|
126
|
+
# See {Capybara::Node::DocumentMatchers#has_title?}
|
|
127
|
+
|
|
128
|
+
##
|
|
129
|
+
# Expectation that page title does not match
|
|
130
|
+
#
|
|
131
|
+
# @!method wont_have_title
|
|
132
|
+
# See {Capybara::Node::DocumentMatchers#has_no_title?}
|
|
128
133
|
|
|
129
134
|
##
|
|
130
135
|
# Expectation that there is select
|
|
131
136
|
#
|
|
132
137
|
# @!method must_have_select
|
|
133
|
-
#
|
|
138
|
+
# See {Capybara::Node::Matchers#has_select?}
|
|
134
139
|
|
|
135
140
|
##
|
|
136
141
|
# Expectation that there is no select
|
|
137
142
|
#
|
|
138
143
|
# @!method wont_have_select
|
|
139
|
-
#
|
|
144
|
+
# See {Capybara::Node::Matchers#has_no_select?}
|
|
140
145
|
|
|
141
146
|
##
|
|
142
|
-
# Expectation that there is
|
|
147
|
+
# Expectation that there is a selector
|
|
143
148
|
#
|
|
144
|
-
# @!method
|
|
145
|
-
#
|
|
149
|
+
# @!method must_have_selector
|
|
150
|
+
# See {Capybara::Node::Matchers#has_selector?}
|
|
146
151
|
|
|
147
152
|
##
|
|
148
|
-
# Expectation that there is no
|
|
153
|
+
# Expectation that there is no selector
|
|
149
154
|
#
|
|
150
|
-
# @!method
|
|
151
|
-
#
|
|
155
|
+
# @!method wont_have_selector
|
|
156
|
+
# See {Capybara::Node::Matchers#has_no_selector?}
|
|
152
157
|
|
|
153
158
|
##
|
|
154
|
-
# Expectation that
|
|
159
|
+
# Expectation that all of the provided selectors are present
|
|
155
160
|
#
|
|
156
|
-
# @!method
|
|
157
|
-
#
|
|
161
|
+
# @!method must_have_all_of_selectors
|
|
162
|
+
# See {Capybara::Node::Matchers#assert_all_of_selectors}
|
|
158
163
|
|
|
159
164
|
##
|
|
160
|
-
# Expectation that
|
|
165
|
+
# Expectation that none of the provided selectors are present
|
|
161
166
|
#
|
|
162
|
-
# @!method
|
|
163
|
-
#
|
|
167
|
+
# @!method must_have_none_of_selectors
|
|
168
|
+
# See {Capybara::Node::Matchers#assert_none_of_selectors}
|
|
164
169
|
|
|
165
170
|
##
|
|
166
|
-
# Expectation that
|
|
171
|
+
# Expectation that any of the provided selectors are present
|
|
167
172
|
#
|
|
168
|
-
# @!method
|
|
169
|
-
#
|
|
173
|
+
# @!method must_have_any_of_selectors
|
|
174
|
+
# See {Capybara::Node::Matchers#assert_any_of_selectors}
|
|
170
175
|
|
|
171
176
|
##
|
|
172
|
-
# Expectation that
|
|
177
|
+
# Expectation that there is a sibling
|
|
173
178
|
#
|
|
174
|
-
# @!method
|
|
175
|
-
#
|
|
179
|
+
# @!method must_have_sibling
|
|
180
|
+
# See {Capybara::Node::Matchers#has_sibling?}
|
|
176
181
|
|
|
177
182
|
##
|
|
178
183
|
# Expectation that element has style
|
|
179
184
|
#
|
|
180
185
|
# @!method must_match_style
|
|
181
|
-
#
|
|
186
|
+
# See {Capybara::Node::Matchers#matches_style?}
|
|
182
187
|
|
|
183
188
|
##
|
|
184
|
-
# Expectation that there is
|
|
189
|
+
# Expectation that there is table
|
|
185
190
|
#
|
|
186
|
-
# @!method
|
|
187
|
-
#
|
|
191
|
+
# @!method must_have_table
|
|
192
|
+
# See {Capybara::Node::Matchers#has_table?}
|
|
188
193
|
|
|
189
194
|
##
|
|
190
|
-
# Expectation that there is
|
|
195
|
+
# Expectation that there is no table
|
|
191
196
|
#
|
|
192
|
-
# @!method
|
|
193
|
-
#
|
|
197
|
+
# @!method wont_have_table
|
|
198
|
+
# See {Capybara::Node::Matchers#has_no_table?}
|
|
199
|
+
|
|
200
|
+
##
|
|
201
|
+
# Expectation that there is xpath
|
|
202
|
+
#
|
|
203
|
+
# @!method must_have_xpath
|
|
204
|
+
# See {Capybara::Node::Matchers#has_xpath?}
|
|
205
|
+
|
|
206
|
+
##
|
|
207
|
+
# Expectation that there is no xpath
|
|
208
|
+
#
|
|
209
|
+
# @!method wont_have_xpath
|
|
210
|
+
# See {Capybara::Node::Matchers#has_no_xpath?}
|
|
211
|
+
|
|
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
|
|
217
|
+
|
|
218
|
+
# rubocop:disable Style/MultilineBlockChain
|
|
219
|
+
(%w[text content title current_path
|
|
220
|
+
selector xpath css link button field select table checked_field unchecked_field
|
|
221
|
+
ancestor sibling].flat_map do |assertion|
|
|
222
|
+
[%W[assert_#{assertion} must_have_#{assertion}],
|
|
223
|
+
%W[refute_#{assertion} wont_have_#{assertion}]]
|
|
224
|
+
end + [%w[assert_all_of_selectors must_have_all_of_selectors],
|
|
225
|
+
%w[assert_none_of_selectors must_have_none_of_selectors],
|
|
226
|
+
%w[assert_any_of_selectors must_have_any_of_selectors],
|
|
227
|
+
%w[assert_matches_style must_match_style]] +
|
|
228
|
+
%w[selector xpath css].flat_map do |assertion|
|
|
229
|
+
[%W[assert_matches_#{assertion} must_match_#{assertion}],
|
|
230
|
+
%W[refute_matches_#{assertion} wont_match_#{assertion}]]
|
|
231
|
+
end).each do |(meth, new_name)|
|
|
232
|
+
class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
|
|
233
|
+
def #{new_name} *args, **kw_args, &block
|
|
234
|
+
::Minitest::Expectation.new(self, ::Minitest::Spec.current).#{new_name}(*args, **kw_args, &block)
|
|
235
|
+
end
|
|
236
|
+
ASSERTION
|
|
237
|
+
|
|
238
|
+
::Minitest::Expectation.class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
|
|
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)
|
|
242
|
+
end
|
|
243
|
+
ASSERTION
|
|
244
|
+
end
|
|
245
|
+
# rubocop:enable Style/MultilineBlockChain
|
|
246
|
+
|
|
247
|
+
##
|
|
248
|
+
# @deprecated
|
|
249
|
+
def must_have_style(*args, **kw_args, &block)
|
|
250
|
+
warn 'must_have_style is deprecated, please use must_match_style'
|
|
251
|
+
must_match_style(*args, **kw_args, &block)
|
|
252
|
+
end
|
|
194
253
|
end
|
|
195
254
|
end
|
|
196
255
|
end
|
|
@@ -308,16 +308,14 @@ module Capybara
|
|
|
308
308
|
|
|
309
309
|
def find_select_or_datalist_input(from, options)
|
|
310
310
|
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
|
311
|
+
find(:select, from, **options)
|
|
312
|
+
rescue Capybara::ElementNotFound => select_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
|
313
|
+
raise if %i[selected with_selected multiple].any? { |option| options.key?(option) }
|
|
314
|
+
|
|
311
315
|
begin
|
|
312
|
-
find(:
|
|
313
|
-
rescue Capybara::ElementNotFound =>
|
|
314
|
-
raise
|
|
315
|
-
|
|
316
|
-
begin
|
|
317
|
-
find(:datalist_input, from, **options)
|
|
318
|
-
rescue Capybara::ElementNotFound => dlinput_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
|
319
|
-
raise Capybara::ElementNotFound, "#{select_error.message} and #{dlinput_error.message}"
|
|
320
|
-
end
|
|
316
|
+
find(:datalist_input, from, **options)
|
|
317
|
+
rescue Capybara::ElementNotFound => dlinput_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
|
318
|
+
raise Capybara::ElementNotFound, "#{select_error.message} and #{dlinput_error.message}"
|
|
321
319
|
end
|
|
322
320
|
end
|
|
323
321
|
end
|
|
@@ -365,20 +363,17 @@ module Capybara
|
|
|
365
363
|
def _check_with_label(selector, checked, locator,
|
|
366
364
|
allow_label_click: session_options.automatic_label_click, **options)
|
|
367
365
|
options[:allow_self] = true if locator.nil?
|
|
368
|
-
|
|
369
366
|
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
|
367
|
+
el = find(selector, locator, **options)
|
|
368
|
+
el.set(checked)
|
|
369
|
+
rescue StandardError => e
|
|
370
|
+
raise unless allow_label_click && catch_error?(e)
|
|
371
|
+
|
|
370
372
|
begin
|
|
371
|
-
el
|
|
372
|
-
el.
|
|
373
|
-
rescue StandardError
|
|
374
|
-
raise
|
|
375
|
-
|
|
376
|
-
begin
|
|
377
|
-
el ||= find(selector, locator, **options.merge(visible: :all))
|
|
378
|
-
el.session.find(:label, for: el, visible: true).click unless el.checked? == checked
|
|
379
|
-
rescue StandardError # swallow extra errors - raise original
|
|
380
|
-
raise e
|
|
381
|
-
end
|
|
373
|
+
el ||= find(selector, locator, **options.merge(visible: :all))
|
|
374
|
+
el.session.find(:label, for: el, visible: true, match: :first).click unless el.checked? == checked
|
|
375
|
+
rescue StandardError # swallow extra errors - raise original
|
|
376
|
+
raise e
|
|
382
377
|
end
|
|
383
378
|
end
|
|
384
379
|
end
|
data/lib/capybara/node/base.rb
CHANGED
|
@@ -103,19 +103,19 @@ module Capybara
|
|
|
103
103
|
|
|
104
104
|
# @api private
|
|
105
105
|
def find_css(css, **options)
|
|
106
|
-
if base.method(:find_css).arity
|
|
107
|
-
base.find_css(css, **options)
|
|
108
|
-
else
|
|
106
|
+
if base.method(:find_css).arity == 1
|
|
109
107
|
base.find_css(css)
|
|
108
|
+
else
|
|
109
|
+
base.find_css(css, **options)
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
# @api private
|
|
114
114
|
def find_xpath(xpath, **options)
|
|
115
|
-
if base.method(:find_xpath).arity
|
|
116
|
-
base.find_xpath(xpath, **options)
|
|
117
|
-
else
|
|
115
|
+
if base.method(:find_xpath).arity == 1
|
|
118
116
|
base.find_xpath(xpath)
|
|
117
|
+
else
|
|
118
|
+
base.find_xpath(xpath, **options)
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
@@ -27,9 +27,11 @@ module Capybara
|
|
|
27
27
|
@query_scope = query_scope
|
|
28
28
|
@query = query
|
|
29
29
|
@allow_reload = false
|
|
30
|
+
@query_idx = nil
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
def allow_reload!
|
|
33
|
+
def allow_reload!(idx = nil)
|
|
34
|
+
@query_idx = idx
|
|
33
35
|
@allow_reload = true
|
|
34
36
|
end
|
|
35
37
|
|
|
@@ -163,6 +165,7 @@ 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
|
# @option options [Integer] y Y coordinate to offset the click location. If {Capybara.configure w3c_click_offset} is `true` the
|
|
165
167
|
# offset will be from the element center, otherwise it will be from the top left corner of the element
|
|
168
|
+
# @option options [Float] delay Delay between the mouse down and mouse up events in seconds (0)
|
|
166
169
|
# @return [Capybara::Node::Element] The element
|
|
167
170
|
def click(*keys, **options)
|
|
168
171
|
perform_click_action(keys, **options) do |k, opts|
|
|
@@ -176,6 +179,7 @@ module Capybara
|
|
|
176
179
|
#
|
|
177
180
|
# @macro action_waiting_behavior
|
|
178
181
|
# @macro click_modifiers
|
|
182
|
+
# @option options [Float] delay Delay between the mouse down and mouse up events in seconds (0)
|
|
179
183
|
# @return [Capybara::Node::Element] The element
|
|
180
184
|
def right_click(*keys, **options)
|
|
181
185
|
perform_click_action(keys, **options) do |k, opts|
|
|
@@ -407,6 +411,8 @@ module Capybara
|
|
|
407
411
|
# @option options [Boolean] :html5 When using Chrome/Firefox with Selenium enables to force the use of HTML5
|
|
408
412
|
# (true) or legacy (false) dragging. If not specified the driver will attempt to
|
|
409
413
|
# detect the correct method to use.
|
|
414
|
+
# @option options [Array<Symbol>,Symbol] :drop_modifiers Modifier keys which should be held while the dragged element is dropped.
|
|
415
|
+
#
|
|
410
416
|
#
|
|
411
417
|
# @return [Capybara::Node::Element] The dragged element
|
|
412
418
|
def drag_to(node, **options)
|
|
@@ -429,11 +435,7 @@ module Capybara
|
|
|
429
435
|
#
|
|
430
436
|
# @return [Capybara::Node::Element] The element
|
|
431
437
|
def drop(*args)
|
|
432
|
-
options = args.map
|
|
433
|
-
return arg.to_path if arg.respond_to?(:to_path)
|
|
434
|
-
|
|
435
|
-
arg
|
|
436
|
-
end
|
|
438
|
+
options = args.map { |arg| arg.respond_to?(:to_path) ? arg.to_path : arg }
|
|
437
439
|
synchronize { base.drop(*options) }
|
|
438
440
|
self
|
|
439
441
|
end
|
|
@@ -545,14 +547,13 @@ module Capybara
|
|
|
545
547
|
|
|
546
548
|
# @api private
|
|
547
549
|
def reload
|
|
548
|
-
|
|
549
|
-
begin
|
|
550
|
-
reloaded = @query.resolve_for(query_scope.reload)&.first
|
|
550
|
+
return self unless @allow_reload
|
|
551
551
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
552
|
+
begin
|
|
553
|
+
reloaded = @query.resolve_for(query_scope.reload)[@query_idx.to_i]
|
|
554
|
+
@base = reloaded.base if reloaded
|
|
555
|
+
rescue StandardError => e
|
|
556
|
+
raise e unless catch_error?(e)
|
|
556
557
|
end
|
|
557
558
|
self
|
|
558
559
|
end
|