capybara 3.20.0 → 3.21.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 +29 -0
- data/README.md +4 -4
- data/lib/capybara/driver/node.rb +4 -0
- data/lib/capybara/helpers.rb +1 -1
- data/lib/capybara/minitest.rb +4 -4
- data/lib/capybara/node/actions.rb +36 -29
- data/lib/capybara/node/element.rb +123 -82
- data/lib/capybara/node/finders.rb +2 -7
- data/lib/capybara/node/simple.rb +1 -0
- data/lib/capybara/selector/definition/css.rb +4 -1
- data/lib/capybara/selector/regexp_disassembler.rb +2 -2
- 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/spec/public/test.js +29 -3
- data/lib/capybara/spec/session/attach_file_spec.rb +13 -5
- data/lib/capybara/spec/session/has_css_spec.rb +4 -3
- data/lib/capybara/spec/session/node_spec.rb +86 -0
- data/lib/capybara/spec/session/scroll_spec.rb +1 -1
- data/lib/capybara/spec/spec_helper.rb +4 -0
- data/lib/capybara/spec/views/with_html.erb +4 -0
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara.rb +19 -11
- 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 +18 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 260a1571a7fde6676b4d901b75e17035cd5c1b32b92f6c647e9d8ceadc78ae2a
|
|
4
|
+
data.tar.gz: d05339eac382154edea4059cf658c7cd828a75bd8b4570b9e85819f1641fad38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ffb2ebe0f747c4519d50138f4575f07c4171b1d2bfaa978dab3f471cac9cf839e0e570b8c25b76185530960d6da42dcdb9a6f45c9ed50ebd605c5cf4da2a4da4
|
|
7
|
+
data.tar.gz: 24c034c08f20d051256444c46bb86e0ab8c8468c34e45e27bf95408074ffe1c305603d0034348582d6b719af36a08f3f88365ddcd0336ba14e8216de854034ef
|
data/History.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
|
+
# Version 3.21.0
|
|
2
|
+
Release date: 2019-05-24
|
|
3
|
+
|
|
4
|
+
### Added
|
|
5
|
+
|
|
6
|
+
* Element#drop - Chrome and Firefox, via the selenium driver, support dropping files/data on elements
|
|
7
|
+
* Default CSS used for `attach_file` `make_visible: true` now includes auto for
|
|
8
|
+
height and width to handle more ways of hiding the file input element
|
|
9
|
+
* Documentation Updates and Fixes - Many thanks to Masafumi Koba! [Masafumi Koba]
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
* Deprecate support for CSS locator being a Symbol
|
|
14
|
+
|
|
15
|
+
# Version 3.20.2
|
|
16
|
+
Release date: 2019-05-19
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
* Move `uglifier` from runtime to development dependency [miyucy]
|
|
21
|
+
|
|
22
|
+
# Version 3.20.1
|
|
23
|
+
Release date: 2019-05-17
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
* RackTest driver considers <template> elements to be non-visible and ignores the contents
|
|
28
|
+
|
|
1
29
|
# Version 3.20.0
|
|
2
30
|
Release date: 2019-05-14
|
|
31
|
+
|
|
3
32
|
### Added
|
|
4
33
|
|
|
5
34
|
* `Node#obscured?` to check viewport presence and element overlap
|
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.21.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
|
data/lib/capybara/driver/node.rb
CHANGED
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
|
data/lib/capybara/minitest.rb
CHANGED
|
@@ -150,27 +150,27 @@ module Capybara
|
|
|
150
150
|
# Assertion that there is xpath
|
|
151
151
|
#
|
|
152
152
|
# @!method assert_xpath
|
|
153
|
-
# see Capybara::Node::Matchers#has_xpath?
|
|
153
|
+
# see {Capybara::Node::Matchers#has_xpath?}
|
|
154
154
|
|
|
155
155
|
##
|
|
156
156
|
# Assertion that there is no xpath
|
|
157
157
|
#
|
|
158
158
|
# @!method refute_xpath
|
|
159
159
|
# @!method assert_no_xpath
|
|
160
|
-
# see Capybara::Node::Matchers#has_no_xpath?
|
|
160
|
+
# see {Capybara::Node::Matchers#has_no_xpath?}
|
|
161
161
|
|
|
162
162
|
##
|
|
163
163
|
# Assertion that there is css
|
|
164
164
|
#
|
|
165
165
|
# @!method assert_css
|
|
166
|
-
# see Capybara::Node::Matchers#has_css?
|
|
166
|
+
# see {Capybara::Node::Matchers#has_css?}
|
|
167
167
|
|
|
168
168
|
##
|
|
169
169
|
# Assertion that there is no css
|
|
170
170
|
#
|
|
171
171
|
# @!method refute_css
|
|
172
172
|
# @!method assert_no_css
|
|
173
|
-
# see Capybara::Node::Matchers#has_no_css?
|
|
173
|
+
# see {Capybara::Node::Matchers#has_no_css?}
|
|
174
174
|
|
|
175
175
|
##
|
|
176
176
|
# 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
|
|