capybara 3.29.0 → 3.31.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 +40 -1
- data/README.md +1 -1
- data/lib/capybara/config.rb +7 -3
- data/lib/capybara/dsl.rb +10 -2
- data/lib/capybara/helpers.rb +3 -1
- data/lib/capybara/minitest.rb +18 -4
- 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 +21 -16
- data/lib/capybara/node/finders.rb +17 -11
- data/lib/capybara/node/matchers.rb +60 -45
- data/lib/capybara/node/simple.rb +4 -2
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/base_query.rb +2 -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/rack_test/node.rb +34 -9
- data/lib/capybara/result.rb +24 -4
- data/lib/capybara/rspec/matchers.rb +27 -27
- 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 +2 -2
- 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 +2 -2
- data/lib/capybara/rspec/matchers/spatial_sugar.rb +2 -1
- data/lib/capybara/selector.rb +24 -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 +4 -2
- data/lib/capybara/selector/definition/radio_button.rb +2 -2
- data/lib/capybara/selector/definition/select.rb +32 -13
- 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/chrome_driver.rb +1 -1
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +2 -2
- data/lib/capybara/selenium/extensions/html5_drag.rb +30 -13
- data/lib/capybara/selenium/node.rb +29 -10
- data/lib/capybara/selenium/nodes/chrome_node.rb +11 -5
- data/lib/capybara/selenium/nodes/edge_node.rb +4 -2
- data/lib/capybara/selenium/nodes/firefox_node.rb +2 -2
- 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 +40 -23
- data/lib/capybara/session/config.rb +6 -2
- data/lib/capybara/session/matchers.rb +6 -6
- data/lib/capybara/spec/public/test.js +51 -6
- data/lib/capybara/spec/session/all_spec.rb +60 -5
- data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
- data/lib/capybara/spec/session/assert_text_spec.rb +9 -5
- data/lib/capybara/spec/session/click_button_spec.rb +5 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +20 -0
- data/lib/capybara/spec/session/find_spec.rb +20 -0
- data/lib/capybara/spec/session/has_css_spec.rb +3 -3
- data/lib/capybara/spec/session/has_select_spec.rb +28 -0
- data/lib/capybara/spec/session/has_table_spec.rb +51 -5
- data/lib/capybara/spec/session/has_text_spec.rb +35 -0
- data/lib/capybara/spec/session/node_spec.rb +106 -2
- 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 +11 -1
- data/lib/capybara/version.rb +1 -1
- data/spec/dsl_spec.rb +2 -2
- data/spec/minitest_spec_spec.rb +46 -46
- data/spec/rack_test_spec.rb +0 -1
- data/spec/regexp_dissassembler_spec.rb +45 -37
- data/spec/result_spec.rb +7 -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 +5 -4
- 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
@@ -7,11 +7,11 @@ module Capybara
|
|
7
7
|
module Matchers
|
8
8
|
class HaveAncestor < CountableWrappedElementMatcher
|
9
9
|
def element_matches?(el)
|
10
|
-
el.assert_ancestor(*@args, &@filter_block)
|
10
|
+
el.assert_ancestor(*@args, **session_query_options, &@filter_block)
|
11
11
|
end
|
12
12
|
|
13
13
|
def element_does_not_match?(el)
|
14
|
-
el.assert_no_ancestor(*@args, &@filter_block)
|
14
|
+
el.assert_no_ancestor(*@args, **session_query_options, &@filter_block)
|
15
15
|
end
|
16
16
|
|
17
17
|
def description
|
@@ -19,7 +19,8 @@ module Capybara
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def query
|
22
|
-
@query ||= Capybara::Queries::AncestorQuery.new(*session_query_args, &@filter_block)
|
22
|
+
# @query ||= Capybara::Queries::AncestorQuery.new(*session_query_args, &@filter_block)
|
23
|
+
@query ||= Capybara::Queries::AncestorQuery.new(*session_query_args, **session_query_options, &@filter_block)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -7,11 +7,11 @@ module Capybara
|
|
7
7
|
module Matchers
|
8
8
|
class HaveCurrentPath < WrappedElementMatcher
|
9
9
|
def element_matches?(el)
|
10
|
-
el.assert_current_path(
|
10
|
+
el.assert_current_path(current_path, **@kw_args)
|
11
11
|
end
|
12
12
|
|
13
13
|
def element_does_not_match?(el)
|
14
|
-
el.assert_no_current_path(
|
14
|
+
el.assert_no_current_path(current_path, **@kw_args)
|
15
15
|
end
|
16
16
|
|
17
17
|
def description
|
@@ -6,12 +6,20 @@ module Capybara
|
|
6
6
|
module RSpecMatchers
|
7
7
|
module Matchers
|
8
8
|
class HaveSelector < CountableWrappedElementMatcher
|
9
|
+
def initialize(*args, **kw_args, &filter_block)
|
10
|
+
super
|
11
|
+
if (RUBY_VERSION >= '2.7') && (@args.size < 2) && @kw_args.keys.any?(String) # rubocop:disable Style/GuardClause
|
12
|
+
@args.push(@kw_args)
|
13
|
+
@kw_args = {}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
def element_matches?(el)
|
10
|
-
el.assert_selector(*@args, &@filter_block)
|
18
|
+
el.assert_selector(*@args, **session_query_options, &@filter_block)
|
11
19
|
end
|
12
20
|
|
13
21
|
def element_does_not_match?(el)
|
14
|
-
el.assert_no_selector(*@args, &@filter_block)
|
22
|
+
el.assert_no_selector(*@args, **session_query_options, &@filter_block)
|
15
23
|
end
|
16
24
|
|
17
25
|
def description
|
@@ -19,13 +27,13 @@ module Capybara
|
|
19
27
|
end
|
20
28
|
|
21
29
|
def query
|
22
|
-
@query ||= Capybara::Queries::SelectorQuery.new(*session_query_args, &@filter_block)
|
30
|
+
@query ||= Capybara::Queries::SelectorQuery.new(*session_query_args, **session_query_options, &@filter_block)
|
23
31
|
end
|
24
32
|
end
|
25
33
|
|
26
34
|
class HaveAllSelectors < WrappedElementMatcher
|
27
35
|
def element_matches?(el)
|
28
|
-
el.assert_all_of_selectors(*@args, &@filter_block)
|
36
|
+
el.assert_all_of_selectors(*@args, **session_query_options, &@filter_block)
|
29
37
|
end
|
30
38
|
|
31
39
|
def does_not_match?(_actual)
|
@@ -39,7 +47,7 @@ module Capybara
|
|
39
47
|
|
40
48
|
class HaveNoSelectors < WrappedElementMatcher
|
41
49
|
def element_matches?(el)
|
42
|
-
el.assert_none_of_selectors(*@args, &@filter_block)
|
50
|
+
el.assert_none_of_selectors(*@args, **session_query_options, &@filter_block)
|
43
51
|
end
|
44
52
|
|
45
53
|
def does_not_match?(_actual)
|
@@ -53,11 +61,11 @@ module Capybara
|
|
53
61
|
|
54
62
|
class HaveAnySelectors < WrappedElementMatcher
|
55
63
|
def element_matches?(el)
|
56
|
-
el.assert_any_of_selectors(*@args, &@filter_block)
|
64
|
+
el.assert_any_of_selectors(*@args, **session_query_options, &@filter_block)
|
57
65
|
end
|
58
66
|
|
59
67
|
def does_not_match?(_actual)
|
60
|
-
el.assert_none_of_selectors(*@args, &@filter_block)
|
68
|
+
el.assert_none_of_selectors(*@args, **session_query_options, &@filter_block)
|
61
69
|
end
|
62
70
|
|
63
71
|
def description
|
@@ -7,11 +7,11 @@ module Capybara
|
|
7
7
|
module Matchers
|
8
8
|
class HaveSibling < CountableWrappedElementMatcher
|
9
9
|
def element_matches?(el)
|
10
|
-
el.assert_sibling(*@args, &@filter_block)
|
10
|
+
el.assert_sibling(*@args, **session_query_options, &@filter_block)
|
11
11
|
end
|
12
12
|
|
13
13
|
def element_does_not_match?(el)
|
14
|
-
el.assert_no_sibling(*@args, &@filter_block)
|
14
|
+
el.assert_no_sibling(*@args, **session_query_options, &@filter_block)
|
15
15
|
end
|
16
16
|
|
17
17
|
def description
|
@@ -19,7 +19,7 @@ module Capybara
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def query
|
22
|
-
@query ||= Capybara::Queries::SiblingQuery.new(*session_query_args, &@filter_block)
|
22
|
+
@query ||= Capybara::Queries::SiblingQuery.new(*session_query_args, **session_query_options, &@filter_block)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -7,11 +7,11 @@ module Capybara
|
|
7
7
|
module Matchers
|
8
8
|
class HaveText < CountableWrappedElementMatcher
|
9
9
|
def element_matches?(el)
|
10
|
-
el.assert_text(*@args)
|
10
|
+
el.assert_text(*@args, **@kw_args)
|
11
11
|
end
|
12
12
|
|
13
13
|
def element_does_not_match?(el)
|
14
|
-
el.assert_no_text(*@args)
|
14
|
+
el.assert_no_text(*@args, **@kw_args)
|
15
15
|
end
|
16
16
|
|
17
17
|
def description
|
@@ -7,11 +7,11 @@ module Capybara
|
|
7
7
|
module Matchers
|
8
8
|
class HaveTitle < WrappedElementMatcher
|
9
9
|
def element_matches?(el)
|
10
|
-
el.assert_title(*@args)
|
10
|
+
el.assert_title(*@args, **@kw_args)
|
11
11
|
end
|
12
12
|
|
13
13
|
def element_does_not_match?(el)
|
14
|
-
el.assert_no_title(*@args)
|
14
|
+
el.assert_no_title(*@args, **@kw_args)
|
15
15
|
end
|
16
16
|
|
17
17
|
def description
|
@@ -7,11 +7,11 @@ module Capybara
|
|
7
7
|
module Matchers
|
8
8
|
class MatchSelector < HaveSelector
|
9
9
|
def element_matches?(el)
|
10
|
-
el.assert_matches_selector(*@args, &@filter_block)
|
10
|
+
el.assert_matches_selector(*@args, **session_query_options, &@filter_block)
|
11
11
|
end
|
12
12
|
|
13
13
|
def element_does_not_match?(el)
|
14
|
-
el.assert_not_matches_selector(*@args, &@filter_block)
|
14
|
+
el.assert_not_matches_selector(*@args, **session_query_options, &@filter_block)
|
15
15
|
end
|
16
16
|
|
17
17
|
def description
|
@@ -19,7 +19,7 @@ module Capybara
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def query
|
22
|
-
@query ||= Capybara::Queries::MatchQuery.new(*session_query_args, &@filter_block)
|
22
|
+
@query ||= Capybara::Queries::MatchQuery.new(*session_query_args, **session_query_options, &@filter_block)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -7,7 +7,7 @@ module Capybara
|
|
7
7
|
module Matchers
|
8
8
|
class MatchStyle < WrappedElementMatcher
|
9
9
|
def element_matches?(el)
|
10
|
-
el.assert_matches_style(*@args)
|
10
|
+
el.assert_matches_style(*@args, **@kw_args)
|
11
11
|
end
|
12
12
|
|
13
13
|
def does_not_match?(_actual)
|
@@ -28,7 +28,7 @@ module Capybara
|
|
28
28
|
##
|
29
29
|
# @deprecated
|
30
30
|
class HaveStyle < MatchStyle
|
31
|
-
def initialize(*args, &filter_block)
|
31
|
+
def initialize(*args, **kw_args, &filter_block)
|
32
32
|
warn 'HaveStyle matcher is deprecated, please use the MatchStyle matcher instead'
|
33
33
|
super
|
34
34
|
end
|
data/lib/capybara/selector.rb
CHANGED
@@ -30,8 +30,8 @@ require 'capybara/selector/definition'
|
|
30
30
|
# * Locator: Matches against the id, {Capybara.configure test_id} attribute, name, placeholder, or
|
31
31
|
# associated label text
|
32
32
|
# * Filters:
|
33
|
-
# * :name (String) - Matches the name attribute
|
34
|
-
# * :placeholder (String) - Matches the placeholder attribute
|
33
|
+
# * :name (String, Regexp) - Matches the name attribute
|
34
|
+
# * :placeholder (String, Regexp) - Matches the placeholder attribute
|
35
35
|
# * :type (String) - Matches the type attribute of the field or element type for 'textarea' and 'select'
|
36
36
|
# * :readonly (Boolean) - Match on the element being readonly
|
37
37
|
# * :with (String, Regexp) - Matches the current value of the field
|
@@ -58,7 +58,7 @@ require 'capybara/selector/definition'
|
|
58
58
|
# * **:button** - Find buttons ( input [of type submit, reset, image, button] or button elements )
|
59
59
|
# * Locator: Matches the id, {Capybara.configure test_id} attribute, name, value, or title attributes, string content of a button, or the alt attribute of an image type button or of a descendant image of a button
|
60
60
|
# * Filters:
|
61
|
-
# * :name (String) - Matches the name attribute
|
61
|
+
# * :name (String, Regexp) - Matches the name attribute
|
62
62
|
# * :title (String) - Matches the title attribute
|
63
63
|
# * :value (String) - Matches the value of an input button
|
64
64
|
# * :type (String) - Matches the type attribute
|
@@ -72,8 +72,8 @@ require 'capybara/selector/definition'
|
|
72
72
|
# * **:fillable_field** - Find text fillable fields ( textarea, input [not of type submit, image, radio, checkbox, hidden, file] )
|
73
73
|
# * Locator: Matches against the id, {Capybara.configure test_id} attribute, name, placeholder, or associated label text
|
74
74
|
# * Filters:
|
75
|
-
# * :name (String) - Matches the name attribute
|
76
|
-
# * :placeholder (String) - Matches the placeholder attribute
|
75
|
+
# * :name (String, Regexp) - Matches the name attribute
|
76
|
+
# * :placeholder (String, Regexp) - Matches the placeholder attribute
|
77
77
|
# * :with (String, Regexp) - Matches the current value of the field
|
78
78
|
# * :type (String) - Matches the type attribute of the field or element type for 'textarea'
|
79
79
|
# * :disabled (Boolean, :all) - Match disabled field? (Default: false)
|
@@ -83,7 +83,7 @@ require 'capybara/selector/definition'
|
|
83
83
|
# * **:radio_button** - Find radio buttons
|
84
84
|
# * Locator: Match id, {Capybara.configure test_id} attribute, name, or associated label text
|
85
85
|
# * Filters:
|
86
|
-
# * :name (String) - Matches the name attribute
|
86
|
+
# * :name (String, Regexp) - Matches the name attribute
|
87
87
|
# * :checked (Boolean) - Match checked fields?
|
88
88
|
# * :unchecked (Boolean) - Match unchecked fields?
|
89
89
|
# * :disabled (Boolean, :all) - Match disabled field? (Default: false)
|
@@ -93,21 +93,23 @@ require 'capybara/selector/definition'
|
|
93
93
|
# * **:checkbox** - Find checkboxes
|
94
94
|
# * Locator: Match id, {Capybara.configure test_id} attribute, name, or associated label text
|
95
95
|
# * Filters:
|
96
|
-
# * :name (String) - Matches the name attribute
|
96
|
+
# * :name (String, Regexp) - Matches the name attribute
|
97
97
|
# * :checked (Boolean) - Match checked fields?
|
98
98
|
# * :unchecked (Boolean) - Match unchecked fields?
|
99
99
|
# * :disabled (Boolean, :all) - Match disabled field? (Default: false)
|
100
|
-
# * :
|
101
|
-
# * :
|
100
|
+
# * :with (String, Regexp) - Match the current value
|
101
|
+
# * :option - Alias of :with
|
102
102
|
#
|
103
103
|
# * **:select** - Find select elements
|
104
104
|
# * Locator: Match id, {Capybara.configure test_id} attribute, name, placeholder, or associated label text
|
105
105
|
# * Filters:
|
106
|
-
# * :name (String) - Matches the name attribute
|
107
|
-
# * :placeholder (String) - Matches the placeholder attribute
|
106
|
+
# * :name (String, Regexp) - Matches the name attribute
|
107
|
+
# * :placeholder (String, Placeholder) - Matches the placeholder attribute
|
108
108
|
# * :disabled (Boolean, :all) - Match disabled field? (Default: false)
|
109
109
|
# * :multiple (Boolean) - Match fields that accept multiple values
|
110
110
|
# * :options (Array<String>) - Exact match options
|
111
|
+
# * :enabled_options (Array<String>) - Exact match enabled options
|
112
|
+
# * :disabled_options (Array<String>) - Exact match disabled options
|
111
113
|
# * :with_options (Array<String>) - Partial match options
|
112
114
|
# * :selected (String, Array<String>) - Match the selection(s)
|
113
115
|
# * :with_selected (String, Array<String>) - Partial match the selection(s)
|
@@ -122,8 +124,8 @@ require 'capybara/selector/definition'
|
|
122
124
|
# * Locator: Matches against the id, {Capybara.configure test_id} attribute, name,
|
123
125
|
# placeholder, or associated label text
|
124
126
|
# * Filters:
|
125
|
-
# * :name (String) - Matches the name attribute
|
126
|
-
# * :placeholder (String) - Matches the placeholder attribute
|
127
|
+
# * :name (String, Regexp) - Matches the name attribute
|
128
|
+
# * :placeholder (String, Regexp) - Matches the placeholder attribute
|
127
129
|
# * :disabled (Boolean, :all) - Match disabled field? (Default: false)
|
128
130
|
# * :options (Array<String>) - Exact match options
|
129
131
|
# * :with_options (Array<String>) - Partial match options
|
@@ -136,7 +138,7 @@ require 'capybara/selector/definition'
|
|
136
138
|
# * **:file_field** - Find file input elements
|
137
139
|
# * Locator: Match id, {Capybara.configure test_id} attribute, name, or associated label text
|
138
140
|
# * Filters:
|
139
|
-
# * :name (String) - Matches the name attribute
|
141
|
+
# * :name (String, Regexp) - Matches the name attribute
|
140
142
|
# * :disabled (Boolean, :all) - Match disabled field? (Default: false)
|
141
143
|
# * :multiple (Boolean) - Match field that accepts multiple values
|
142
144
|
#
|
@@ -174,9 +176,15 @@ Capybara::Selector::FilterSet.add(:_field) do
|
|
174
176
|
node_filter(:unchecked, :boolean) { |node, value| (value ^ node.checked?) }
|
175
177
|
node_filter(:disabled, :boolean, default: false, skip_if: :all) { |node, value| !(value ^ node.disabled?) }
|
176
178
|
node_filter(:valid, :boolean) { |node, value| node.evaluate_script('this.validity.valid') == value }
|
179
|
+
node_filter(:name) { |node, value| !value.is_a?(Regexp) || value.match?(node[:name]) }
|
180
|
+
node_filter(:placeholder) { |node, value| !value.is_a?(Regexp) || value.match?(node[:placeholder]) }
|
177
181
|
|
178
|
-
expression_filter(:name)
|
179
|
-
|
182
|
+
expression_filter(:name) do |xpath, val|
|
183
|
+
builder(xpath).add_attribute_conditions(name: val)
|
184
|
+
end
|
185
|
+
expression_filter(:placeholder) do |xpath, val|
|
186
|
+
builder(xpath).add_attribute_conditions(placeholder: val)
|
187
|
+
end
|
180
188
|
expression_filter(:disabled) { |xpath, val| val ? xpath : xpath[~XPath.attr(:disabled)] }
|
181
189
|
expression_filter(:multiple) { |xpath, val| xpath[val ? XPath.attr(:multiple) : ~XPath.attr(:multiple)] }
|
182
190
|
|
@@ -166,7 +166,7 @@ module Capybara
|
|
166
166
|
|
167
167
|
def locator_filter(*types, **options, &block)
|
168
168
|
types.each { |type| options[type] = true }
|
169
|
-
@locator_filter = Capybara::Selector::Filters::LocatorFilter.new(block, options) if block
|
169
|
+
@locator_filter = Capybara::Selector::Filters::LocatorFilter.new(block, **options) if block
|
170
170
|
@locator_filter
|
171
171
|
end
|
172
172
|
|
@@ -181,7 +181,7 @@ module Capybara
|
|
181
181
|
describe(:expression_filters, &block)
|
182
182
|
else
|
183
183
|
describe(:expression_filters) do |**options|
|
184
|
-
describe_all_expression_filters(options)
|
184
|
+
describe_all_expression_filters(**options)
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
@@ -26,7 +26,7 @@ Capybara.add_selector(:button, locator_type: [String, Symbol]) do
|
|
26
26
|
image_btn_xpath = image_btn_xpath[alt_matches]
|
27
27
|
end
|
28
28
|
|
29
|
-
%i[value title type
|
29
|
+
%i[value title type].inject(input_btn_xpath.union(btn_xpath).union(image_btn_xpath)) do |memo, ef|
|
30
30
|
memo[find_by_attr(ef, options[ef])]
|
31
31
|
end
|
32
32
|
end
|
@@ -34,10 +34,15 @@ Capybara.add_selector(:button, locator_type: [String, Symbol]) do
|
|
34
34
|
node_filter(:disabled, :boolean, default: false, skip_if: :all) { |node, value| !(value ^ node.disabled?) }
|
35
35
|
expression_filter(:disabled) { |xpath, val| val ? xpath : xpath[~XPath.attr(:disabled)] }
|
36
36
|
|
37
|
+
node_filter(:name) { |node, value| !value.is_a?(Regexp) || value.match?(node[:name]) }
|
38
|
+
expression_filter(:name) do |xpath, val|
|
39
|
+
builder(xpath).add_attribute_conditions(name: val)
|
40
|
+
end
|
41
|
+
|
37
42
|
describe_expression_filters do |disabled: nil, **options|
|
38
43
|
desc = +''
|
39
44
|
desc << ' that is not disabled' if disabled == false
|
40
|
-
desc << describe_all_expression_filters(options)
|
45
|
+
desc << describe_all_expression_filters(**options)
|
41
46
|
end
|
42
47
|
|
43
48
|
describe_node_filters do |disabled: nil, **|
|
@@ -5,7 +5,7 @@ Capybara.add_selector(:checkbox, locator_type: [String, Symbol]) do
|
|
5
5
|
xpath = XPath.axis(allow_self ? :"descendant-or-self" : :descendant, :input)[
|
6
6
|
XPath.attr(:type) == 'checkbox'
|
7
7
|
]
|
8
|
-
locate_field(xpath, locator, options)
|
8
|
+
locate_field(xpath, locator, **options)
|
9
9
|
end
|
10
10
|
|
11
11
|
filter_set(:_field, %i[checked unchecked disabled name])
|
@@ -20,7 +20,7 @@ Capybara.add_selector(:checkbox, locator_type: [String, Symbol]) do
|
|
20
20
|
describe_node_filters do |option: nil, with: nil, **|
|
21
21
|
desc = +''
|
22
22
|
desc << " with value #{option.inspect}" if option
|
23
|
-
desc << " with value #{with.
|
23
|
+
desc << " with value #{with.inspect}" if with
|
24
24
|
desc
|
25
25
|
end
|
26
26
|
end
|
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
Capybara.add_selector(:css, locator_type: [String, Symbol], raw_locator: true) do
|
4
4
|
css do |css|
|
5
|
-
|
5
|
+
if css.is_a? Symbol
|
6
|
+
warn "DEPRECATED: Passing a symbol (#{css.inspect}) as the CSS locator is deprecated - please pass a string instead."
|
7
|
+
end
|
6
8
|
css
|
7
9
|
end
|
8
10
|
end
|
@@ -5,7 +5,7 @@ Capybara.add_selector(:datalist_input, locator_type: [String, Symbol]) do
|
|
5
5
|
|
6
6
|
xpath do |locator, **options|
|
7
7
|
xpath = XPath.descendant(:input)[XPath.attr(:list)]
|
8
|
-
locate_field(xpath, locator, options)
|
8
|
+
locate_field(xpath, locator, **options)
|
9
9
|
end
|
10
10
|
|
11
11
|
filter_set(:_field, %i[disabled name placeholder])
|
@@ -16,7 +16,7 @@ Capybara.add_selector(:datalist_option, locator_type: [String, Symbol]) do
|
|
16
16
|
describe_expression_filters do |disabled: nil, **options|
|
17
17
|
desc = +''
|
18
18
|
desc << ' that is not disabled' if disabled == false
|
19
|
-
desc << describe_all_expression_filters(options)
|
19
|
+
desc << describe_all_expression_filters(**options)
|
20
20
|
end
|
21
21
|
|
22
22
|
describe_node_filters do |**options|
|
@@ -19,7 +19,7 @@ Capybara.add_selector(:element, locator_type: [String, Symbol]) do
|
|
19
19
|
|
20
20
|
describe_expression_filters do |**options|
|
21
21
|
booleans, values = options.partition { |_k, v| [true, false].include? v }.map(&:to_h)
|
22
|
-
desc = describe_all_expression_filters(values)
|
22
|
+
desc = describe_all_expression_filters(**values)
|
23
23
|
desc + booleans.map do |k, v|
|
24
24
|
v ? " with #{k} attribute" : "without #{k} attribute"
|
25
25
|
end.join
|
@@ -7,7 +7,7 @@ Capybara.add_selector(:field, locator_type: [String, Symbol]) do
|
|
7
7
|
invalid_types = %w[submit image]
|
8
8
|
invalid_types << 'hidden' unless options[:type].to_s == 'hidden'
|
9
9
|
xpath = XPath.descendant(:input, :textarea, :select)[!XPath.attr(:type).one_of(*invalid_types)]
|
10
|
-
locate_field(xpath, locator, options)
|
10
|
+
locate_field(xpath, locator, **options)
|
11
11
|
end
|
12
12
|
|
13
13
|
expression_filter(:type) do |expr, type|
|
@@ -6,7 +6,7 @@ Capybara.add_selector(:file_field, locator_type: [String, Symbol]) do
|
|
6
6
|
xpath = XPath.axis(allow_self ? :"descendant-or-self" : :descendant, :input)[
|
7
7
|
XPath.attr(:type) == 'file'
|
8
8
|
]
|
9
|
-
locate_field(xpath, locator, options)
|
9
|
+
locate_field(xpath, locator, **options)
|
10
10
|
end
|
11
11
|
|
12
12
|
filter_set(:_field, %i[disabled multiple name])
|