capybara 3.21.0 → 3.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/History.md +14 -0
- data/README.md +13 -8
- data/lib/capybara.rb +38 -32
- data/lib/capybara/driver/node.rb +2 -2
- data/lib/capybara/minitest.rb +14 -1
- data/lib/capybara/minitest/spec.rb +20 -7
- data/lib/capybara/node/finders.rb +41 -47
- data/lib/capybara/node/matchers.rb +161 -72
- data/lib/capybara/queries/ancestor_query.rb +9 -7
- data/lib/capybara/queries/sibling_query.rb +11 -4
- data/lib/capybara/result.rb +2 -0
- data/lib/capybara/rspec/matchers.rb +16 -1
- data/lib/capybara/rspec/matchers/have_ancestor.rb +30 -0
- data/lib/capybara/rspec/matchers/have_sibling.rb +30 -0
- data/lib/capybara/selector.rb +153 -171
- data/lib/capybara/selector/definition/checkbox.rb +8 -5
- data/lib/capybara/selector/definition/radio_button.rb +8 -5
- data/lib/capybara/selector/filter_set.rb +4 -2
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +35 -1
- data/lib/capybara/session.rb +74 -71
- data/lib/capybara/session/config.rb +1 -1
- data/lib/capybara/spec/session/check_spec.rb +6 -0
- data/lib/capybara/spec/session/choose_spec.rb +6 -0
- data/lib/capybara/spec/session/has_ancestor_spec.rb +44 -0
- data/lib/capybara/spec/session/has_sibling_spec.rb +50 -0
- data/lib/capybara/spec/session/select_spec.rb +5 -5
- data/lib/capybara/spec/views/form.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +10 -10
- data/spec/minitest_spec.rb +11 -1
- data/spec/minitest_spec_spec.rb +11 -1
- data/spec/regexp_dissassembler_spec.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33bde7b48182b5c3dd5679c621882392d87bc8b9303cffabf963fe84186768b1
|
4
|
+
data.tar.gz: 4d9ccd2f5c45a87586f87f29f9df888af7102bf6e86042993c36ed858fc07537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a128be647b867602954cc51cf603e020c3eceb938b5761766982a00e91fd0fccbc7aff02c49fc2c3064cdf489cc7a812c25818b5ca675ddf87c6a7a6822bd45a
|
7
|
+
data.tar.gz: 40d9831cc35bf0d1af71722718cea81ac2a075b5bbc067a89edb78e56572d8e0ad56455abd47b2b5ba3e0edd5b76ed4eb77de63255773e70cfd261bfa064092f
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup markdown
|
data/History.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# Version 3.22.0
|
2
|
+
Release date: 2019-05-29
|
3
|
+
|
4
|
+
### Added
|
5
|
+
|
6
|
+
* `ancestor`/`sibling` assertions and matchers added
|
7
|
+
* Documentation Updates and Fixes - Many thanks again to Masafumi Koba! [Masafumi Koba]
|
8
|
+
* Added `:with` alias for `:option` filter on `:checkbox` and `:radio_button` selectors
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
* Selenium driver with Chrome >= 73 now resets cookies and local/session storage after navigating
|
13
|
+
to 'about:blank' when possible to minimize potential race condition
|
14
|
+
|
1
15
|
# Version 3.21.0
|
2
16
|
Release date: 2019-05-24
|
3
17
|
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
8
8
|
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=capybara&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=capybara&package-manager=bundler&version-scheme=semver)
|
9
9
|
|
10
|
-
**Note** You are viewing the README for the 3.
|
10
|
+
**Note** You are viewing the README for the 3.22.x version of Capybara.
|
11
11
|
|
12
12
|
|
13
13
|
Capybara helps you test web applications by simulating how a real user would
|
@@ -925,12 +925,17 @@ Capybara.default_selector = :xpath
|
|
925
925
|
find('.//ul/li').text
|
926
926
|
```
|
927
927
|
|
928
|
-
Capybara
|
929
|
-
|
928
|
+
Capybara provides a number of other built-in selector types. The full list, along
|
929
|
+
with applicable filters, can be seen at [built-in selectors](https://www.rubydoc.info/github/teamcapybara/capybara/Capybara/Selector)
|
930
|
+
|
931
|
+
Capybara also allows you to add custom selectors, which can be very useful if you
|
932
|
+
find yourself using the same kinds of selectors very often. The examples below are very
|
933
|
+
simple, and there are many available features not demonstrated. For more in-depth examples
|
934
|
+
please see Capybaras built-in selector definitions.
|
930
935
|
|
931
936
|
```ruby
|
932
|
-
Capybara.add_selector(:
|
933
|
-
xpath { |id| XPath.descendant[XPath.attr(:
|
937
|
+
Capybara.add_selector(:my_attribute) do
|
938
|
+
xpath { |id| XPath.descendant[XPath.attr(:my_attribute) == id.to_s] }
|
934
939
|
end
|
935
940
|
|
936
941
|
Capybara.add_selector(:row) do
|
@@ -947,9 +952,9 @@ an XPath expression generated through the XPath gem. You can now use these
|
|
947
952
|
selectors like this:
|
948
953
|
|
949
954
|
```ruby
|
950
|
-
find(:
|
951
|
-
find(:row, 3)
|
952
|
-
find(:flash_type, :notice)
|
955
|
+
find(:my_attribute, 'post_123') # find element with matching attribute
|
956
|
+
find(:row, 3) # find 3rd row in table body
|
957
|
+
find(:flash_type, :notice) # find element with id of 'flash' and class of 'notice'
|
953
958
|
```
|
954
959
|
|
955
960
|
## <a name="beware-the-xpath--trap"></a>Beware the XPath // trap
|
data/lib/capybara.rb
CHANGED
@@ -66,38 +66,44 @@ module Capybara
|
|
66
66
|
# config.app_host = 'http://www.google.com'
|
67
67
|
# end
|
68
68
|
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
69
|
+
# #### Configurable options
|
70
|
+
#
|
71
|
+
# - **allow_gumbo** (Boolean = `false`) - When `nokogumbo` is available, whether it will be used to parse HTML strings.
|
72
|
+
# - **always_include_port** (Boolean = `false`) - Whether the Rack server's port should automatically be inserted into every visited URL
|
73
|
+
# unless another port is explicitly specified.
|
74
|
+
# - **app_host** (String, `nil`) - The default host to use when giving a relative URL to visit, must be a valid URL e.g. `http://www.example.com`.
|
75
|
+
# - **asset_host** (String = `nil`) - Where dynamic assets are hosted - will be prepended to relative asset locations if present.
|
76
|
+
# - **automatic_label_click** (Boolean = `false`) - Whether {Capybara::Node::Element#choose Element#choose}, {Capybara::Node::Element#check Element#check},
|
77
|
+
# {Capybara::Node::Element#uncheck Element#uncheck} will attempt to click the associated `<label>` element if the checkbox/radio button are non-visible.
|
78
|
+
# - **automatic_reload** (Boolean = `true`) - Whether to automatically reload elements as Capybara is waiting.
|
79
|
+
# - **default_max_wait_time** (Numeric = `2`) - The maximum number of seconds to wait for asynchronous processes to finish.
|
80
|
+
# - **default_normalize_ws** (Boolean = `false`) - Whether text predicates and matchers use normalize whitespace behavior.
|
81
|
+
# - **default_selector** (`:css`, `:xpath` = `:css`) - Methods which take a selector use the given type by default. See also {Capybara::Selector}.
|
82
|
+
# - **default_set_options** (Hash = `{}`) - The default options passed to {Capybara::Node::Element#set Element#set}.
|
83
|
+
# - **enable_aria_label** (Boolean = `false`) - Whether fields, links, and buttons will match against `aria-label` attribute.
|
84
|
+
# - **exact** (Boolean = `false`) - Whether locators are matched exactly or with substrings. Only affects selector conditions
|
85
|
+
# written using the `XPath#is` method.
|
86
|
+
# - **exact_text** (Boolean = `false`) - Whether the text matchers and `:text` filter match exactly or on substrings.
|
87
|
+
# - **ignore_hidden_elements** (Boolean = `true`) - Whether to ignore hidden elements on the page.
|
88
|
+
# - **match** (`:one`, `:first`, `:prefer_exact`, `:smart` = `:smart`) - The matching strategy to find nodes.
|
89
|
+
# - **predicates_wait** (Boolean = `true`) - Whether Capybara's predicate matchers use waiting behavior by default.
|
90
|
+
# - **raise_server_errors** (Boolean = `true`) - Should errors raised in the server be raised in the tests?
|
91
|
+
# - **reuse_server** (Boolean = `true`) - Whether to reuse the server thread between multiple sessions using the same app object.
|
92
|
+
# - **run_server** (Boolean = `true`) - Whether to start a Rack server for the given Rack app.
|
93
|
+
# - **save_path** (String = `Dir.pwd`) - Where to put pages saved through {Capybara::Session#save_page save_page}, {Capybara::Session#save_screenshot save_screenshot},
|
94
|
+
# {Capybara::Session#save_and_open_page save_and_open_page}, or {Capybara::Session#save_and_open_screenshot save_and_open_screenshot}.
|
95
|
+
# - **server** (Symbol = `:default` (which uses puma)) - The name of the registered server to use when running the app under test.
|
96
|
+
# - **server_errors** (Array\<Class> = `[Exception]`) - Error classes that should be raised in the tests if they are raised in the server
|
97
|
+
# and {configure raise_server_errors} is `true`.
|
98
|
+
# - **test_id** (`Symbol`, `String`, `nil` = `nil`) - Optional attribute to match locator against with built-in selectors along with id.
|
99
|
+
# - **threadsafe** (Boolean = `false`) - Whether sessions can be configured individually.
|
100
|
+
#
|
101
|
+
# #### DSL Options
|
102
|
+
#
|
103
|
+
# When using `capybara/dsl`, the following options are also available:
|
104
|
+
#
|
105
|
+
# - **default_driver** (Symbol = `:rack_test`) - The name of the driver to use by default.
|
106
|
+
# - **javascript_driver** (Symbol = `:selenium`) - The name of a driver to use for JavaScript enabled tests.
|
101
107
|
#
|
102
108
|
def configure
|
103
109
|
yield config
|
data/lib/capybara/driver/node.rb
CHANGED
@@ -31,8 +31,8 @@ module Capybara
|
|
31
31
|
raise NotImplementedError
|
32
32
|
end
|
33
33
|
|
34
|
-
# @param value String
|
35
|
-
# @param options [Hash
|
34
|
+
# @param value [String, Array] Array is only allowed if node has 'multiple' attribute
|
35
|
+
# @param options [Hash] Driver specific options for how to set a value on a node
|
36
36
|
def set(value, **options)
|
37
37
|
raise NotImplementedError
|
38
38
|
end
|
data/lib/capybara/minitest.rb
CHANGED
@@ -86,9 +86,20 @@ module Capybara
|
|
86
86
|
# @!method assert_matches_style
|
87
87
|
# see {Capybara::Node::Matchers#assert_matches_style}
|
88
88
|
|
89
|
+
## Assert element has a matching sibling
|
90
|
+
#
|
91
|
+
# @!method assert_sibling
|
92
|
+
# see {Capybara::Node::Matchers#assert_sibling}
|
93
|
+
|
94
|
+
## Assert element has a matching ancestor
|
95
|
+
#
|
96
|
+
# @!method assert_ancestor
|
97
|
+
# see {Capybara::Node::Matchers#assert_ancestor}
|
98
|
+
|
89
99
|
%w[selector no_selector matches_style
|
90
100
|
all_of_selectors none_of_selectors any_of_selectors
|
91
|
-
matches_selector not_matches_selector
|
101
|
+
matches_selector not_matches_selector
|
102
|
+
sibling no_sibling ancestor no_ancestor].each do |assertion_name|
|
92
103
|
class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
|
93
104
|
def assert_#{assertion_name} *args, &optional_filter_block
|
94
105
|
self.assertions +=1
|
@@ -102,6 +113,8 @@ module Capybara
|
|
102
113
|
|
103
114
|
alias_method :refute_selector, :assert_no_selector
|
104
115
|
alias_method :refute_matches_selector, :assert_not_matches_selector
|
116
|
+
alias_method :refute_ancestor, :assert_no_ancestor
|
117
|
+
alias_method :refute_sibling, :assert_no_sibling
|
105
118
|
|
106
119
|
%w[xpath css link button field select table].each do |selector_type|
|
107
120
|
define_method "assert_#{selector_type}" do |*args, &optional_filter_block|
|
@@ -11,13 +11,14 @@ module Capybara
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# rubocop:disable Style/MultilineBlockChain
|
14
|
-
(%w[selector xpath css link button field select table checked_field unchecked_field
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
(%w[selector xpath css link button field select table checked_field unchecked_field
|
15
|
+
ancestor sibling].flat_map do |assertion|
|
16
|
+
[%W[assert_#{assertion} must_have_#{assertion}],
|
17
|
+
%W[refute_#{assertion} wont_have_#{assertion}]]
|
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]] +
|
21
22
|
%w[selector xpath css].flat_map do |assertion|
|
22
23
|
[%W[assert_matches_#{assertion} must_match_#{assertion}],
|
23
24
|
%W[refute_matches_#{assertion} wont_match_#{assertion}]]
|
@@ -178,6 +179,18 @@ module Capybara
|
|
178
179
|
#
|
179
180
|
# @!method must_match_style
|
180
181
|
# see {Capybara::Node::Matchers#assert_matches_style}
|
182
|
+
|
183
|
+
##
|
184
|
+
# Expectation that there is an ancestor
|
185
|
+
#
|
186
|
+
# @!method must_have_ancestor
|
187
|
+
# see Capybara::Node::Matchers#has_ancestor?
|
188
|
+
|
189
|
+
##
|
190
|
+
# Expectation that there is a sibling
|
191
|
+
#
|
192
|
+
# @!method must_have_sibling
|
193
|
+
# see Capybara::Node::Matchers#has_sibling?
|
181
194
|
end
|
182
195
|
end
|
183
196
|
end
|
@@ -5,21 +5,25 @@ module Capybara
|
|
5
5
|
module Finders
|
6
6
|
##
|
7
7
|
#
|
8
|
-
# Find an {Capybara::Node::Element} based on the given arguments.
|
8
|
+
# Find an {Capybara::Node::Element} based on the given arguments. {#find} will raise an error if the element
|
9
9
|
# is not found.
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# page.find('#foo').find('.bar')
|
12
|
+
# page.find(:xpath, './/div[contains(., "bar")]')
|
13
|
+
# page.find('li', text: 'Quox').click_link('Delete')
|
14
14
|
#
|
15
|
-
# @param (see
|
15
|
+
# @param (see #all)
|
16
16
|
#
|
17
17
|
# @macro waiting_behavior
|
18
18
|
#
|
19
19
|
# @!macro system_filters
|
20
20
|
# @option options [String, Regexp] text Only find elements which contain this text or match this regexp
|
21
|
-
# @option options [String, Boolean] exact_text
|
22
|
-
#
|
21
|
+
# @option options [String, Boolean] exact_text
|
22
|
+
# When String the elements contained text must match exactly, when Boolean controls whether the `text` option must match exactly.
|
23
|
+
# Defaults to {Capybara.configure exact_text}.
|
24
|
+
# @option options [Boolean] normalize_ws
|
25
|
+
# Whether the `text`/`exact_text` options are compared against elment text with whitespace normalized or as returned by the driver.
|
26
|
+
# Defaults to {Capybara.configure default_normalize_ws}.
|
23
27
|
# @option options [Boolean, Symbol] visible Only find elements with the specified visibility:
|
24
28
|
# * true - only finds visible elements.
|
25
29
|
# * false - finds invisible _and_ visible elements.
|
@@ -31,12 +35,14 @@ module Capybara
|
|
31
35
|
# * false - only find elements whose centerpoint is in the viewport and is not obscured by other non-descendant elements.
|
32
36
|
# @option options [String, Regexp] id Only find elements with an id that matches the value passed
|
33
37
|
# @option options [String, Array<String>, Regexp] class Only find elements with matching class/classes.
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
38
|
+
# * Absence of a class can be checked by prefixing the class name with `!`
|
39
|
+
# * If you need to check for existence of a class name that starts with `!` then prefix with `!!`
|
40
|
+
#
|
41
|
+
# class:['a', '!b', '!!!c'] # limit to elements with class 'a' and '!c' but not class 'b'
|
42
|
+
#
|
37
43
|
# @option options [String, Regexp, Hash] style Only find elements with matching style. String and Regexp will be checked against text of the elements `style` attribute, while a Hash will be compared against the elements full style
|
38
|
-
# @option options [Boolean] exact Control whether `is` expressions in the given XPath match exactly or partially
|
39
|
-
#
|
44
|
+
# @option options [Boolean] exact Control whether `is` expressions in the given XPath match exactly or partially. Defaults to {Capybara.configure exact}.
|
45
|
+
# @option options [Symbol] match The matching strategy to use. Defaults to {Capybara.configure match}.
|
40
46
|
#
|
41
47
|
# @return [Capybara::Node::Element] The found element
|
42
48
|
# @raise [Capybara::ElementNotFound] If the element can't be found before time expires
|
@@ -48,21 +54,19 @@ module Capybara
|
|
48
54
|
|
49
55
|
##
|
50
56
|
#
|
51
|
-
# Find an {Capybara::Node::Element} based on the given arguments that is also an ancestor of the element called on.
|
52
|
-
# is not found.
|
57
|
+
# Find an {Capybara::Node::Element} based on the given arguments that is also an ancestor of the element called on.
|
58
|
+
# {#ancestor} will raise an error if the element is not found.
|
53
59
|
#
|
54
|
-
#
|
60
|
+
# {#ancestor} takes the same options as {#find}.
|
55
61
|
#
|
56
62
|
# element.ancestor('#foo').find('.bar')
|
57
63
|
# element.ancestor(:xpath, './/div[contains(., "bar")]')
|
58
64
|
# element.ancestor('ul', text: 'Quox').click_link('Delete')
|
59
65
|
#
|
60
|
-
# @param (see
|
66
|
+
# @param (see #find)
|
61
67
|
#
|
62
68
|
# @macro waiting_behavior
|
63
69
|
#
|
64
|
-
# @option options [Symbol] match The matching strategy to use.
|
65
|
-
#
|
66
70
|
# @return [Capybara::Node::Element] The found element
|
67
71
|
# @raise [Capybara::ElementNotFound] If the element can't be found before time expires
|
68
72
|
#
|
@@ -73,22 +77,19 @@ module Capybara
|
|
73
77
|
|
74
78
|
##
|
75
79
|
#
|
76
|
-
# Find an {Capybara::Node::Element} based on the given arguments that is also a sibling of the element called on.
|
77
|
-
# is not found.
|
78
|
-
#
|
80
|
+
# Find an {Capybara::Node::Element} based on the given arguments that is also a sibling of the element called on.
|
81
|
+
# {#sibling} will raise an error if the element is not found.
|
79
82
|
#
|
80
|
-
#
|
83
|
+
# {#sibling} takes the same options as {#find}.
|
81
84
|
#
|
82
85
|
# element.sibling('#foo').find('.bar')
|
83
86
|
# element.sibling(:xpath, './/div[contains(., "bar")]')
|
84
87
|
# element.sibling('ul', text: 'Quox').click_link('Delete')
|
85
88
|
#
|
86
|
-
# @param (see
|
89
|
+
# @param (see #find)
|
87
90
|
#
|
88
91
|
# @macro waiting_behavior
|
89
92
|
#
|
90
|
-
# @option options [Symbol] match The matching strategy to use.
|
91
|
-
#
|
92
93
|
# @return [Capybara::Node::Element] The found element
|
93
94
|
# @raise [Capybara::ElementNotFound] If the element can't be found before time expires
|
94
95
|
#
|
@@ -102,7 +103,7 @@ module Capybara
|
|
102
103
|
# Find a form field on the page. The field can be found by its name, id or label text.
|
103
104
|
#
|
104
105
|
# @overload find_field([locator], **options)
|
105
|
-
# @param [String] locator name, id, Capybara.test_id attribute, placeholder or text of associated label element
|
106
|
+
# @param [String] locator name, id, {Capybara.configure test_id} attribute, placeholder or text of associated label element
|
106
107
|
#
|
107
108
|
# @macro waiting_behavior
|
108
109
|
#
|
@@ -117,13 +118,12 @@ module Capybara
|
|
117
118
|
# @option options [String, Regexp] with Value of field to match on
|
118
119
|
# @option options [String] type Type of field to match on
|
119
120
|
# @option options [Boolean] multiple Match fields that can have multiple values?
|
120
|
-
# @option options [String, Regexp] id
|
121
|
+
# @option options [String, Regexp] id Match fields that match the id attribute
|
121
122
|
# @option options [String] name Match fields that match the name attribute
|
122
123
|
# @option options [String] placeholder Match fields that match the placeholder attribute
|
123
124
|
# @option options [String, Array<String>, Regexp] class Match fields that match the class(es) passed
|
124
125
|
# @return [Capybara::Node::Element] The found element
|
125
126
|
#
|
126
|
-
|
127
127
|
def find_field(locator = nil, **options, &optional_filter_block)
|
128
128
|
find(:field, locator, options, &optional_filter_block)
|
129
129
|
end
|
@@ -133,12 +133,12 @@ module Capybara
|
|
133
133
|
# Find a link on the page. The link can be found by its id or text.
|
134
134
|
#
|
135
135
|
# @overload find_link([locator], **options)
|
136
|
-
# @param [String] locator id, Capybara.test_id attribute, title, text, or alt of enclosed img element
|
136
|
+
# @param [String] locator id, {Capybara.configure test_id} attribute, title, text, or alt of enclosed img element
|
137
137
|
#
|
138
138
|
# @macro waiting_behavior
|
139
139
|
#
|
140
|
-
# @option options [String,Regexp,nil] href
|
141
|
-
# @option options [String, Regexp] id
|
140
|
+
# @option options [String,Regexp,nil] href Value to match against the links href, if `nil` finds link placeholders (`<a>` elements with no href attribute), if `false` ignores the href
|
141
|
+
# @option options [String, Regexp] id Match links with the id provided
|
142
142
|
# @option options [String] title Match links with the title provided
|
143
143
|
# @option options [String] alt Match links with a contained img element whose alt matches
|
144
144
|
# @option options [String, Array<String>, Regexp] class Match links that match the class(es) provided
|
@@ -151,14 +151,12 @@ module Capybara
|
|
151
151
|
##
|
152
152
|
#
|
153
153
|
# Find a button on the page.
|
154
|
-
# This can be any
|
155
|
-
#
|
156
|
-
# by their text content, and image
|
154
|
+
# This can be any `<input>` element of type submit, reset, image, button or it can be a
|
155
|
+
# `<button>` element. All buttons can be found by their id, name, {Capybara.configure test_id} attribute, value, or title.
|
156
|
+
# `<button>` elements can also be found by their text content, and image `<input>` elements by their alt attribute.
|
157
157
|
#
|
158
158
|
# @overload find_button([locator], **options)
|
159
|
-
# @param [String] locator id, name, Capybara.test_id attribute, value, title, text content, alt of image
|
160
|
-
#
|
161
|
-
# @overload find_button(**options)
|
159
|
+
# @param [String] locator id, name, {Capybara.configure test_id} attribute, value, title, text content, alt of image
|
162
160
|
#
|
163
161
|
# @macro waiting_behavior
|
164
162
|
#
|
@@ -204,9 +202,8 @@ module Capybara
|
|
204
202
|
# page.all(:css, 'a#person_123')
|
205
203
|
# page.all(:xpath, './/a[@id="person_123"]')
|
206
204
|
#
|
207
|
-
#
|
208
205
|
# If the type of selector is left out, Capybara uses
|
209
|
-
# {Capybara.default_selector}. It's set to
|
206
|
+
# {Capybara.configure default_selector}. It's set to `:css` by default.
|
210
207
|
#
|
211
208
|
# page.all("a#person_123")
|
212
209
|
#
|
@@ -219,28 +216,25 @@ module Capybara
|
|
219
216
|
# page.all('a', text: 'Home')
|
220
217
|
# page.all('#menu li', visible: true)
|
221
218
|
#
|
222
|
-
# By default Capybara's waiting behavior will wait up to
|
219
|
+
# By default Capybara's waiting behavior will wait up to {Capybara.configure default_max_wait_time}
|
223
220
|
# seconds for matching elements to be available and then return an empty result if none
|
224
221
|
# are available. It is possible to set expectations on the number of results located and
|
225
222
|
# Capybara will raise an exception if the number of elements located don't satisfy the
|
226
|
-
# specified conditions.
|
223
|
+
# specified conditions. The expectations can be set using:
|
227
224
|
#
|
228
225
|
# page.assert_selector('p#foo', count: 4)
|
229
226
|
# page.assert_selector('p#foo', maximum: 10)
|
230
227
|
# page.assert_selector('p#foo', minimum: 1)
|
231
228
|
# page.assert_selector('p#foo', between: 1..10)
|
232
229
|
#
|
233
|
-
#
|
234
|
-
# count matching.
|
235
|
-
#
|
236
|
-
# @param [Symbol] kind Optional selector type (:css, :xpath, :field, etc.) - Defaults to Capybara.default_selector
|
230
|
+
# @param [Symbol] kind Optional selector type (:css, :xpath, :field, etc.). Defaults to {Capybara.configure default_selector}.
|
237
231
|
# @param [String] locator The locator for the specified selector
|
238
232
|
# @macro system_filters
|
233
|
+
# @macro waiting_behavior
|
239
234
|
# @option options [Integer] count Exact number of matches that are expected to be found
|
240
235
|
# @option options [Integer] maximum Maximum number of matches that are expected to be found
|
241
236
|
# @option options [Integer] minimum Minimum number of matches that are expected to be found
|
242
237
|
# @option options [Range] between Number of matches found must be within the given range
|
243
|
-
# @option options [false, true, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear.
|
244
238
|
# @overload all([kind = Capybara.default_selector], locator = nil, **options)
|
245
239
|
# @overload all([kind = Capybara.default_selector], locator = nil, **options, &filter_block)
|
246
240
|
# @yieldparam element [Capybara::Node::Element] The element being considered for inclusion in the results
|
@@ -271,7 +265,7 @@ module Capybara
|
|
271
265
|
##
|
272
266
|
#
|
273
267
|
# Find the first element on the page matching the given selector
|
274
|
-
# and options. By default
|
268
|
+
# and options. By default {#first} will wait up to {Capybara.configure default_max_wait_time}
|
275
269
|
# seconds for matching elements to appear and then raise an error if no matching
|
276
270
|
# element is found, or `nil` if the provided count options allow for empty results.
|
277
271
|
#
|