capybara 3.20.2 → 3.22.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/.yardopts +1 -0
- data/History.md +28 -0
- data/README.md +16 -11
- data/lib/capybara/driver/node.rb +6 -2
- data/lib/capybara/helpers.rb +1 -1
- data/lib/capybara/minitest/spec.rb +20 -7
- data/lib/capybara/minitest.rb +18 -5
- data/lib/capybara/node/actions.rb +36 -29
- data/lib/capybara/node/element.rb +123 -82
- data/lib/capybara/node/finders.rb +42 -53
- 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/have_ancestor.rb +30 -0
- data/lib/capybara/rspec/matchers/have_sibling.rb +30 -0
- data/lib/capybara/rspec/matchers.rb +16 -1
- data/lib/capybara/selector/definition/checkbox.rb +8 -5
- data/lib/capybara/selector/definition/css.rb +4 -1
- data/lib/capybara/selector/definition/radio_button.rb +8 -5
- data/lib/capybara/selector/filter_set.rb +4 -2
- data/lib/capybara/selector/regexp_disassembler.rb +2 -2
- data/lib/capybara/selector.rb +153 -171
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +35 -1
- data/lib/capybara/selenium/extensions/html5_drag.rb +63 -0
- data/lib/capybara/selenium/node.rb +4 -0
- data/lib/capybara/selenium/nodes/chrome_node.rb +4 -0
- data/lib/capybara/selenium/nodes/firefox_node.rb +4 -13
- data/lib/capybara/selenium/nodes/ie_node.rb +14 -3
- data/lib/capybara/selenium/nodes/safari_node.rb +0 -13
- data/lib/capybara/session/config.rb +1 -1
- data/lib/capybara/session.rb +74 -71
- data/lib/capybara/spec/public/test.js +29 -3
- data/lib/capybara/spec/session/attach_file_spec.rb +13 -5
- 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_css_spec.rb +4 -3
- data/lib/capybara/spec/session/has_sibling_spec.rb +50 -0
- data/lib/capybara/spec/session/node_spec.rb +85 -0
- data/lib/capybara/spec/session/select_spec.rb +5 -5
- data/lib/capybara/spec/spec_helper.rb +4 -0
- data/lib/capybara/spec/views/form.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +10 -10
- data/lib/capybara.rb +42 -36
- data/spec/minitest_spec.rb +11 -1
- data/spec/minitest_spec_spec.rb +11 -1
- data/spec/regexp_dissassembler_spec.rb +1 -1
- data/spec/selenium_spec_firefox.rb +2 -0
- data/spec/selenium_spec_ie.rb +13 -7
- data/spec/selenium_spec_safari.rb +2 -0
- data/spec/shared_selenium_session.rb +1 -51
- metadata +9 -4
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,31 @@
|
|
|
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
|
+
|
|
15
|
+
# Version 3.21.0
|
|
16
|
+
Release date: 2019-05-24
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
* Element#drop - Chrome and Firefox, via the selenium driver, support dropping files/data on elements
|
|
21
|
+
* Default CSS used for `attach_file` `make_visible: true` now includes auto for
|
|
22
|
+
height and width to handle more ways of hiding the file input element
|
|
23
|
+
* Documentation Updates and Fixes - Many thanks to Masafumi Koba! [Masafumi Koba]
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
* Deprecate support for CSS locator being a Symbol
|
|
28
|
+
|
|
1
29
|
# Version 3.20.2
|
|
2
30
|
Release date: 2019-05-19
|
|
3
31
|
|
data/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
8
8
|
[](https://dependabot.com/compatibility-score.html?dependency-name=capybara&package-manager=bundler&version-scheme=semver)
|
|
9
9
|
|
|
10
|
-
**Note** You are viewing the README for the 3.
|
|
10
|
+
**Note** You are viewing the README for the 3.22.x version of Capybara.
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
Capybara helps you test web applications by simulating how a real user would
|
|
@@ -38,8 +38,6 @@ GitHub): http://groups.google.com/group/ruby-capybara
|
|
|
38
38
|
- [RackTest](#racktest)
|
|
39
39
|
- [Selenium](#selenium)
|
|
40
40
|
- [Apparition](#apparition)
|
|
41
|
-
- [Capybara-webkit](#capybara-webkit)
|
|
42
|
-
- [Poltergeist](#poltergeist)
|
|
43
41
|
- [The DSL](#the-dsl)
|
|
44
42
|
- [Navigating](#navigating)
|
|
45
43
|
- [Clicking links and buttons](#clicking-links-and-buttons)
|
|
@@ -59,11 +57,13 @@ GitHub): http://groups.google.com/group/ruby-capybara
|
|
|
59
57
|
- [Using the DSL elsewhere](#using-the-dsl-elsewhere)
|
|
60
58
|
- [Calling remote servers](#calling-remote-servers)
|
|
61
59
|
- [Using sessions](#using-sessions)
|
|
60
|
+
- [Named sessions](#named-sessions)
|
|
61
|
+
- [Using sessions manually](#using-sessions-manually)
|
|
62
62
|
- [XPath, CSS and selectors](#xpath-css-and-selectors)
|
|
63
63
|
- [Beware the XPath // trap](#beware-the-xpath--trap)
|
|
64
64
|
- [Configuring and adding drivers](#configuring-and-adding-drivers)
|
|
65
65
|
- [Gotchas:](#gotchas)
|
|
66
|
-
- ["Threadsafe" mode](#threadsafe)
|
|
66
|
+
- ["Threadsafe" mode](#threadsafe-mode)
|
|
67
67
|
- [Development](#development)
|
|
68
68
|
|
|
69
69
|
## <a name="key-benefits"></a>Key benefits
|
|
@@ -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/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
|
|
@@ -69,6 +69,10 @@ module Capybara
|
|
|
69
69
|
raise NotImplementedError
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
def drop(*args)
|
|
73
|
+
raise NotImplementedError
|
|
74
|
+
end
|
|
75
|
+
|
|
72
76
|
def scroll_by(x, y)
|
|
73
77
|
raise NotImplementedError
|
|
74
78
|
end
|
data/lib/capybara/helpers.rb
CHANGED
|
@@ -41,7 +41,7 @@ module Capybara
|
|
|
41
41
|
##
|
|
42
42
|
#
|
|
43
43
|
# Injects a `<base>` tag into the given HTML code, pointing to
|
|
44
|
-
#
|
|
44
|
+
# {Capybara.configure asset_host}.
|
|
45
45
|
#
|
|
46
46
|
# @param [String] html HTML code to inject into
|
|
47
47
|
# @param [URL] host (Capybara.asset_host) The host from which assets should be loaded
|
|
@@ -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
|
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|
|
|
@@ -150,27 +163,27 @@ module Capybara
|
|
|
150
163
|
# Assertion that there is xpath
|
|
151
164
|
#
|
|
152
165
|
# @!method assert_xpath
|
|
153
|
-
# see Capybara::Node::Matchers#has_xpath?
|
|
166
|
+
# see {Capybara::Node::Matchers#has_xpath?}
|
|
154
167
|
|
|
155
168
|
##
|
|
156
169
|
# Assertion that there is no xpath
|
|
157
170
|
#
|
|
158
171
|
# @!method refute_xpath
|
|
159
172
|
# @!method assert_no_xpath
|
|
160
|
-
# see Capybara::Node::Matchers#has_no_xpath?
|
|
173
|
+
# see {Capybara::Node::Matchers#has_no_xpath?}
|
|
161
174
|
|
|
162
175
|
##
|
|
163
176
|
# Assertion that there is css
|
|
164
177
|
#
|
|
165
178
|
# @!method assert_css
|
|
166
|
-
# see Capybara::Node::Matchers#has_css?
|
|
179
|
+
# see {Capybara::Node::Matchers#has_css?}
|
|
167
180
|
|
|
168
181
|
##
|
|
169
182
|
# Assertion that there is no css
|
|
170
183
|
#
|
|
171
184
|
# @!method refute_css
|
|
172
185
|
# @!method assert_no_css
|
|
173
|
-
# see Capybara::Node::Matchers#has_no_css?
|
|
186
|
+
# see {Capybara::Node::Matchers#has_no_css?}
|
|
174
187
|
|
|
175
188
|
##
|
|
176
189
|
# Assertion that there is link
|
|
@@ -6,18 +6,19 @@ module Capybara
|
|
|
6
6
|
# @!macro waiting_behavior
|
|
7
7
|
# If the driver is capable of executing JavaScript, this method will wait for a set amount of time
|
|
8
8
|
# and continuously retry finding the element until either the element is found or the time
|
|
9
|
-
# expires. The length of time
|
|
9
|
+
# expires. The length of time this method will wait is controlled through {Capybara.configure default_max_wait_time}.
|
|
10
10
|
#
|
|
11
|
-
# @option options [false, true, Numeric] wait
|
|
11
|
+
# @option options [false, true, Numeric] wait
|
|
12
|
+
# Maximum time to wait for matching element to appear. Defaults to {Capybara.configure default_max_wait_time}.
|
|
12
13
|
|
|
13
14
|
##
|
|
14
15
|
#
|
|
15
|
-
# Finds a button or link and clicks it.
|
|
16
|
-
# {
|
|
16
|
+
# Finds a button or link and clicks it. See {#click_button} and
|
|
17
|
+
# {#click_link} for what locator will match against for each type of element.
|
|
17
18
|
#
|
|
18
19
|
# @overload click_link_or_button([locator], **options)
|
|
19
20
|
# @macro waiting_behavior
|
|
20
|
-
# @param [String] locator See {
|
|
21
|
+
# @param [String] locator See {#click_button} and {#click_link}
|
|
21
22
|
#
|
|
22
23
|
# @return [Capybara::Node::Element] The element clicked
|
|
23
24
|
#
|
|
@@ -28,13 +29,13 @@ module Capybara
|
|
|
28
29
|
|
|
29
30
|
##
|
|
30
31
|
#
|
|
31
|
-
# Finds a link by id, Capybara.test_id attribute, text or title and clicks it. Also looks at image
|
|
32
|
+
# Finds a link by id, {Capybara.configure test_id} attribute, text or title and clicks it. Also looks at image
|
|
32
33
|
# alt text inside the link.
|
|
33
34
|
#
|
|
34
35
|
# @overload click_link([locator], **options)
|
|
35
36
|
# @macro waiting_behavior
|
|
36
|
-
# @param [String] locator text, id, Capybara.test_id attribute, title or nested image's alt attribute
|
|
37
|
-
# @param options
|
|
37
|
+
# @param [String] locator text, id, {Capybara.configure test_id} attribute, title or nested image's alt attribute
|
|
38
|
+
# @param [Hash] options See {Capybara::Node::Finders#find_link}
|
|
38
39
|
#
|
|
39
40
|
# @return [Capybara::Node::Element] The element clicked
|
|
40
41
|
def click_link(locator = nil, **options)
|
|
@@ -44,14 +45,14 @@ module Capybara
|
|
|
44
45
|
##
|
|
45
46
|
#
|
|
46
47
|
# Finds a button on the page and clicks it.
|
|
47
|
-
# This can be any
|
|
48
|
-
#
|
|
49
|
-
# by their text content, and image
|
|
48
|
+
# This can be any `<input>` element of type submit, reset, image, button or it can be a
|
|
49
|
+
# `<button>` element. All buttons can be found by their id, name, {Capybara.configure test_id} attribute, value, or title. `<button>` elements can also be found
|
|
50
|
+
# by their text content, and image `<input>` elements by their alt attribute.
|
|
50
51
|
#
|
|
51
52
|
# @overload click_button([locator], **options)
|
|
52
53
|
# @macro waiting_behavior
|
|
53
54
|
# @param [String] locator Which button to find
|
|
54
|
-
# @param options
|
|
55
|
+
# @param [Hash] options See {Capybara::Node::Finders#find_button}
|
|
55
56
|
# @return [Capybara::Node::Element] The element clicked
|
|
56
57
|
def click_button(locator = nil, **options)
|
|
57
58
|
find(:button, locator, options).click
|
|
@@ -59,9 +60,9 @@ module Capybara
|
|
|
59
60
|
|
|
60
61
|
##
|
|
61
62
|
#
|
|
62
|
-
# Locate a text field or text area and fill it in with the given text
|
|
63
|
-
# The field can be found via its name, id, Capybara.test_id attribute, or label text.
|
|
64
|
-
# If no locator is provided will operate on self or a descendant
|
|
63
|
+
# Locate a text field or text area and fill it in with the given text.
|
|
64
|
+
# The field can be found via its name, id, {Capybara.configure test_id} attribute, or label text.
|
|
65
|
+
# If no locator is provided this will operate on self or a descendant.
|
|
65
66
|
#
|
|
66
67
|
# # will fill in a descendant fillable field with name, id, or label text matching 'Name'
|
|
67
68
|
# page.fill_in 'Name', with: 'Bob'
|
|
@@ -73,7 +74,7 @@ module Capybara
|
|
|
73
74
|
# @overload fill_in([locator], with:, **options)
|
|
74
75
|
# @param [String] locator Which field to fill in
|
|
75
76
|
# @param [Hash] options
|
|
76
|
-
# @param with: [String] The value to
|
|
77
|
+
# @param with: [String] The value to fill in
|
|
77
78
|
# @macro waiting_behavior
|
|
78
79
|
# @option options [String] currently_with The current value property of the field to fill in
|
|
79
80
|
# @option options [Boolean] multiple Match fields that can have multiple values?
|
|
@@ -81,9 +82,9 @@ module Capybara
|
|
|
81
82
|
# @option options [String] name Match fields that match the name attribute
|
|
82
83
|
# @option options [String] placeholder Match fields that match the placeholder attribute
|
|
83
84
|
# @option options [String, Array<String>, Regexp] class Match fields that match the class(es) provided
|
|
84
|
-
# @option options [Hash] fill_options Driver specific options regarding how to fill fields (Defaults come from Capybara.default_set_options)
|
|
85
|
+
# @option options [Hash] fill_options Driver specific options regarding how to fill fields (Defaults come from {Capybara.configure default_set_options})
|
|
85
86
|
#
|
|
86
|
-
# @return [Capybara::Node::Element] The element
|
|
87
|
+
# @return [Capybara::Node::Element] The element filled in
|
|
87
88
|
def fill_in(locator = nil, with:, currently_with: nil, fill_options: {}, **find_options)
|
|
88
89
|
find_options[:with] = currently_with if currently_with
|
|
89
90
|
find_options[:allow_self] = true if locator.nil?
|
|
@@ -91,7 +92,8 @@ module Capybara
|
|
|
91
92
|
end
|
|
92
93
|
|
|
93
94
|
# @!macro label_click
|
|
94
|
-
# @option options [Boolean] allow_label_click
|
|
95
|
+
# @option options [Boolean] allow_label_click
|
|
96
|
+
# Attempt to click the label to toggle state if element is non-visible. Defaults to {Capybara.configure automatic_label_click}.
|
|
95
97
|
|
|
96
98
|
##
|
|
97
99
|
#
|
|
@@ -178,10 +180,10 @@ module Capybara
|
|
|
178
180
|
|
|
179
181
|
##
|
|
180
182
|
#
|
|
181
|
-
# If
|
|
183
|
+
# If `from` option is present, {#select} finds a select box, or text input with associated datalist,
|
|
182
184
|
# on the page and selects a particular option from it.
|
|
183
185
|
# Otherwise it finds an option inside current scope and selects it.
|
|
184
|
-
# If the select box is a multiple select,
|
|
186
|
+
# If the select box is a multiple select, {#select} can be called multiple times to select more than
|
|
185
187
|
# one option.
|
|
186
188
|
# The select box can be found via its name, id or label text. The option can be found by its text.
|
|
187
189
|
#
|
|
@@ -191,7 +193,7 @@ module Capybara
|
|
|
191
193
|
# @macro waiting_behavior
|
|
192
194
|
#
|
|
193
195
|
# @param value [String] Which option to select
|
|
194
|
-
# @param from [String] The id, Capybara.test_id attribute, name or label of the select box
|
|
196
|
+
# @param from [String] The id, {Capybara.configure test_id} attribute, name or label of the select box
|
|
195
197
|
#
|
|
196
198
|
# @return [Capybara::Node::Element] The option element selected
|
|
197
199
|
def select(value = nil, from: nil, **options)
|
|
@@ -209,7 +211,7 @@ module Capybara
|
|
|
209
211
|
##
|
|
210
212
|
#
|
|
211
213
|
# Find a select box on the page and unselect a particular option from it. If the select
|
|
212
|
-
# box is a multiple select,
|
|
214
|
+
# box is a multiple select, {#unselect} can be called multiple times to unselect more than
|
|
213
215
|
# one option. The select box can be found via its name, id or label text.
|
|
214
216
|
#
|
|
215
217
|
# page.unselect 'March', from: 'Month'
|
|
@@ -218,7 +220,7 @@ module Capybara
|
|
|
218
220
|
# @macro waiting_behavior
|
|
219
221
|
#
|
|
220
222
|
# @param value [String] Which option to unselect
|
|
221
|
-
# @param from [String] The id, Capybara.test_id attribute, name or label of the select box
|
|
223
|
+
# @param from [String] The id, {Capybara.configure test_id} attribute, name or label of the select box
|
|
222
224
|
#
|
|
223
225
|
#
|
|
224
226
|
# @return [Capybara::Node::Element] The option element unselected
|
|
@@ -232,7 +234,7 @@ module Capybara
|
|
|
232
234
|
##
|
|
233
235
|
#
|
|
234
236
|
# Find a descendant file field on the page and attach a file given its path. There are two ways to use
|
|
235
|
-
#
|
|
237
|
+
# {#attach_file}, in the first method the file field can be found via its name, id or label text.
|
|
236
238
|
# In the case of the file field being hidden for
|
|
237
239
|
# styling reasons the `make_visible` option can be used to temporarily change the CSS of
|
|
238
240
|
# the file field, attach the file, and then revert the CSS back to original. If no locator is
|
|
@@ -257,13 +259,16 @@ module Capybara
|
|
|
257
259
|
# @param [String] locator Which field to attach the file to
|
|
258
260
|
# @param [String, Array<String>] paths The path(s) of the file(s) that will be attached
|
|
259
261
|
#
|
|
260
|
-
# @option options [Symbol] match
|
|
261
|
-
#
|
|
262
|
+
# @option options [Symbol] match
|
|
263
|
+
# The matching strategy to use (:one, :first, :prefer_exact, :smart). Defaults to {Capybara.configure match}.
|
|
264
|
+
# @option options [Boolean] exact
|
|
265
|
+
# Match the exact label name/contents or accept a partial match. Defaults to {Capybara.configure exact}.
|
|
262
266
|
# @option options [Boolean] multiple Match field which allows multiple file selection
|
|
263
267
|
# @option options [String, Regexp] id Match fields that match the id attribute
|
|
264
268
|
# @option options [String] name Match fields that match the name attribute
|
|
265
269
|
# @option options [String, Array<String>, Regexp] class Match fields that match the class(es) provided
|
|
266
|
-
# @option options [true, Hash] make_visible
|
|
270
|
+
# @option options [true, Hash] make_visible
|
|
271
|
+
# A Hash of CSS styles to change before attempting to attach the file, if `true`, `{ opacity: 1, display: 'block', visibility: 'visible' }` is used (may not be supported by all drivers).
|
|
267
272
|
# @overload attach_file(paths, &blk)
|
|
268
273
|
# @param [String, Array<String>] paths The path(s) of the file(s) that will be attached
|
|
269
274
|
# @yield Block whose actions will trigger the system file chooser to be shown
|
|
@@ -326,7 +331,9 @@ module Capybara
|
|
|
326
331
|
end
|
|
327
332
|
|
|
328
333
|
def while_visible(element, visible_css)
|
|
329
|
-
|
|
334
|
+
if visible_css == true
|
|
335
|
+
visible_css = { opacity: 1, display: 'block', visibility: 'visible', width: 'auto', height: 'auto' }
|
|
336
|
+
end
|
|
330
337
|
_update_style(element, visible_css)
|
|
331
338
|
raise ExpectationNotMet, 'The style changes in :make_visible did not make the file input visible' unless element.visible?
|
|
332
339
|
|