capybara 3.10.1 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +13 -0
- data/README.md +2 -3
- data/lib/capybara.rb +16 -6
- data/lib/capybara/minitest.rb +8 -9
- data/lib/capybara/node/actions.rb +31 -28
- data/lib/capybara/node/base.rb +2 -1
- data/lib/capybara/node/document_matchers.rb +6 -2
- data/lib/capybara/node/element.rb +10 -10
- data/lib/capybara/node/finders.rb +13 -14
- data/lib/capybara/node/matchers.rb +1 -3
- data/lib/capybara/node/simple.rb +10 -2
- data/lib/capybara/queries/base_query.rb +7 -3
- data/lib/capybara/queries/selector_query.rb +60 -34
- data/lib/capybara/queries/style_query.rb +5 -1
- data/lib/capybara/queries/text_query.rb +2 -2
- data/lib/capybara/queries/title_query.rb +1 -1
- data/lib/capybara/rack_test/node.rb +16 -2
- data/lib/capybara/result.rb +9 -4
- data/lib/capybara/rspec/features.rb +4 -4
- data/lib/capybara/rspec/matcher_proxies.rb +3 -1
- data/lib/capybara/rspec/matchers.rb +25 -287
- data/lib/capybara/rspec/matchers/base.rb +98 -0
- data/lib/capybara/rspec/matchers/become_closed.rb +33 -0
- data/lib/capybara/rspec/matchers/compound.rb +88 -0
- data/lib/capybara/rspec/matchers/have_current_path.rb +29 -0
- data/lib/capybara/rspec/matchers/have_selector.rb +69 -0
- data/lib/capybara/rspec/matchers/have_style.rb +23 -0
- data/lib/capybara/rspec/matchers/have_text.rb +33 -0
- data/lib/capybara/rspec/matchers/have_title.rb +29 -0
- data/lib/capybara/rspec/matchers/match_selector.rb +27 -0
- data/lib/capybara/selector.rb +48 -20
- data/lib/capybara/selector/builders/xpath_builder.rb +3 -3
- data/lib/capybara/selector/css.rb +5 -5
- data/lib/capybara/selector/filters/base.rb +11 -3
- data/lib/capybara/selector/filters/expression_filter.rb +3 -3
- data/lib/capybara/selector/filters/node_filter.rb +16 -2
- data/lib/capybara/selector/regexp_disassembler.rb +116 -17
- data/lib/capybara/selector/selector.rb +52 -26
- data/lib/capybara/selenium/driver.rb +6 -2
- data/lib/capybara/selenium/node.rb +15 -14
- data/lib/capybara/selenium/nodes/marionette_node.rb +19 -5
- data/lib/capybara/selenium/patches/pause_duration_fix.rb +1 -3
- data/lib/capybara/server.rb +6 -1
- data/lib/capybara/server/animation_disabler.rb +1 -1
- data/lib/capybara/session.rb +4 -2
- data/lib/capybara/session/matchers.rb +7 -3
- data/lib/capybara/spec/public/test.js +5 -5
- data/lib/capybara/spec/session/all_spec.rb +5 -0
- data/lib/capybara/spec/session/has_css_spec.rb +4 -4
- data/lib/capybara/spec/session/has_field_spec.rb +17 -0
- data/lib/capybara/spec/session/node_spec.rb +45 -4
- data/lib/capybara/spec/spec_helper.rb +6 -1
- data/lib/capybara/spec/views/frame_child.erb +1 -1
- data/lib/capybara/spec/views/obscured.erb +44 -0
- data/lib/capybara/spec/views/with_html.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/spec/rack_test_spec.rb +15 -0
- data/spec/regexp_dissassembler_spec.rb +88 -8
- data/spec/selector_spec.rb +3 -0
- data/spec/selenium_spec_chrome.rb +9 -15
- data/spec/selenium_spec_chrome_remote.rb +3 -2
- data/spec/selenium_spec_firefox_remote.rb +6 -2
- metadata +54 -3
- data/lib/capybara/rspec/compound.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c349d493d1d6639b40265451f5b357aa7b5d29d279e1095284071fba9bc8a59
|
4
|
+
data.tar.gz: 23350dd400ffd3e11fdda081f12331ab7518b94061fb104355e30cfbee0d9935
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caa9124c0465dcc82b15109c4cbd841dbc8e214ff87fd928a712abd6896155c6c8b3be00d0ec09cb1fbbea9da8206773b799766da5fd08ac9bc0a9d36d81dd85
|
7
|
+
data.tar.gz: 18b0c515e7be809183bc26d6d2ce38692561e30760b96a26992d44b96027484ae942f7c25e48b803323ef0534ca616fd20c503ec2cfefbf1da47416eb30b2443
|
data/History.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# Version 3.11.0
|
2
|
+
Release date: 2018-11-14
|
3
|
+
|
4
|
+
### Added
|
5
|
+
|
6
|
+
* Ability for node filters to set detailed error messages
|
7
|
+
* `Capybara::HTML` Will use `nokogumbo` for HTML parsing if installed
|
8
|
+
* `Selector#locator_filter` added to allow for dynamic locator in selectors
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
* Node filters are evaluated in the context of the Selector they are used in to ensure the correct options are used
|
13
|
+
|
1
14
|
# Version 3.10.1
|
2
15
|
Release date: 2018-11-03
|
3
16
|
|
data/README.md
CHANGED
@@ -6,8 +6,7 @@
|
|
6
6
|
[![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)
|
7
7
|
[![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)
|
8
8
|
|
9
|
-
**Note** You are viewing the README for the
|
10
|
-
you can find the README at https://github.com/teamcapybara/capybara/blob/3.10_stable/README.md
|
9
|
+
**Note** You are viewing the README for the 3.11.0 version of Capybara.
|
11
10
|
|
12
11
|
|
13
12
|
Capybara helps you test web applications by simulating how a real user would
|
@@ -409,7 +408,7 @@ and test server, see "Transactions and database setup" below.
|
|
409
408
|
|
410
409
|
### <a name="capybara-webkit"></a>Capybara-webkit
|
411
410
|
|
412
|
-
Note: `capybara-webkit` depends on QtWebkit which went EOL quite some time ago. There has been an attempt to revive the project but `capybara-webkit` is not yet (AFAIK) compatible with the revived version of QtWebKit (could be a good OSS project for someone) and as such is still limited to an old version of QtWebKit. This means its support for modern JS and CSS is severely limited.
|
411
|
+
Note: `capybara-webkit` depends on QtWebkit which went EOL quite some time ago. There has been an attempt to revive the project but `capybara-webkit` is not yet (AFAIK) compatible with the revived version of QtWebKit (could be a good OSS project for someone) and as such is still limited to an old version of QtWebKit. This means its support for modern JS and CSS is severely limited.
|
413
412
|
|
414
413
|
The [capybara-webkit driver](https://github.com/thoughtbot/capybara-webkit) is for true headless
|
415
414
|
testing. It uses QtWebKit to start a rendering engine process. It can execute JavaScript as well.
|
data/lib/capybara.rb
CHANGED
@@ -366,9 +366,18 @@ module Capybara
|
|
366
366
|
# @return [Nokogiri::HTML::Document] HTML document
|
367
367
|
#
|
368
368
|
def HTML(html) # rubocop:disable Naming/MethodName
|
369
|
-
Nokogiri
|
370
|
-
|
371
|
-
textarea
|
369
|
+
if Nokogiri.respond_to?(:HTML5) # Nokogumbo installed
|
370
|
+
Nokogiri::HTML5(html).tap do |document|
|
371
|
+
document.xpath('//textarea').each do |textarea|
|
372
|
+
# The Nokogumbo HTML5 parser already returns spec compliant contents
|
373
|
+
textarea['_capybara_raw_value'] = textarea.content
|
374
|
+
end
|
375
|
+
end
|
376
|
+
else
|
377
|
+
Nokogiri::HTML(html).tap do |document|
|
378
|
+
document.xpath('//textarea').each do |textarea|
|
379
|
+
textarea['_capybara_raw_value'] = textarea.content.sub(/\A\n/, '')
|
380
|
+
end
|
372
381
|
end
|
373
382
|
end
|
374
383
|
end
|
@@ -460,7 +469,8 @@ end
|
|
460
469
|
|
461
470
|
Capybara.register_server :webrick do |app, port, host, **options|
|
462
471
|
require 'rack/handler/webrick'
|
463
|
-
|
472
|
+
options = { Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log.new(nil, 0) }.merge(options)
|
473
|
+
Rack::Handler::WEBrick.run(app, options)
|
464
474
|
end
|
465
475
|
|
466
476
|
Capybara.register_server :puma do |app, port, host, **options|
|
@@ -476,8 +486,8 @@ Capybara.register_server :puma do |app, port, host, **options|
|
|
476
486
|
# If we just run the Puma Rack handler it installs signal handlers which prevent us from being able to interrupt tests.
|
477
487
|
# Therefore construct and run the Server instance ourselves.
|
478
488
|
# Rack::Handler::Puma.run(app, { Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false }.merge(options))
|
479
|
-
|
480
|
-
conf = Rack::Handler::Puma.config(app,
|
489
|
+
options = { Host: host, Port: port, Threads: '0:4', workers: 0, daemon: false }.merge(options)
|
490
|
+
conf = Rack::Handler::Puma.config(app, options)
|
481
491
|
events = conf.options[:Silent] ? ::Puma::Events.strings : ::Puma::Events.stdio
|
482
492
|
|
483
493
|
events.log 'Capybara starting Puma...'
|
data/lib/capybara/minitest.rb
CHANGED
@@ -42,12 +42,12 @@ module Capybara
|
|
42
42
|
# @!method assert_no_current_path
|
43
43
|
# see {Capybara::SessionMatchers#assert_no_current_path}
|
44
44
|
|
45
|
-
%w[
|
45
|
+
%w[text no_text title no_title current_path no_current_path].each do |assertion_name|
|
46
46
|
class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
|
47
|
-
def #{assertion_name} *args
|
47
|
+
def assert_#{assertion_name} *args
|
48
48
|
self.assertions +=1
|
49
49
|
subject, args = determine_subject(args)
|
50
|
-
subject
|
50
|
+
subject.assert_#{assertion_name}(*args)
|
51
51
|
rescue Capybara::ExpectationNotMet => e
|
52
52
|
raise ::Minitest::Assertion, e.message
|
53
53
|
end
|
@@ -86,15 +86,14 @@ module Capybara
|
|
86
86
|
# @!method assert_style
|
87
87
|
# see {Capybara::Node::Matchers#assert_style}
|
88
88
|
|
89
|
-
%w[
|
90
|
-
|
91
|
-
|
92
|
-
assert_style].each do |assertion_name|
|
89
|
+
%w[selector no_selector style
|
90
|
+
all_of_selectors none_of_selectors any_of_selectors
|
91
|
+
matches_selector not_matches_selector].each do |assertion_name|
|
93
92
|
class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
|
94
|
-
def #{assertion_name} *args, &optional_filter_block
|
93
|
+
def assert_#{assertion_name} *args, &optional_filter_block
|
95
94
|
self.assertions +=1
|
96
95
|
subject, args = determine_subject(args)
|
97
|
-
subject
|
96
|
+
subject.assert_#{assertion_name}(*args, &optional_filter_block)
|
98
97
|
rescue Capybara::ExpectationNotMet => e
|
99
98
|
raise ::Minitest::Assertion, e.message
|
100
99
|
end
|
@@ -3,19 +3,20 @@
|
|
3
3
|
module Capybara
|
4
4
|
module Node
|
5
5
|
module Actions
|
6
|
-
##
|
7
|
-
#
|
8
|
-
# Finds a button or link and clicks it. See {Capybara::Node::Actions#click_button} and
|
9
|
-
# {Capybara::Node::Actions#click_link} for what locator will match against for each type of element
|
10
6
|
# @!macro waiting_behavior
|
11
|
-
# If the driver is capable of executing JavaScript,
|
7
|
+
# If the driver is capable of executing JavaScript, this method will wait for a set amount of time
|
12
8
|
# and continuously retry finding the element until either the element is found or the time
|
13
9
|
# expires. The length of time +find+ will wait is controlled through {Capybara.default_max_wait_time}
|
14
10
|
#
|
15
11
|
# @option options [false, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear.
|
12
|
+
|
13
|
+
##
|
16
14
|
#
|
17
|
-
#
|
15
|
+
# Finds a button or link and clicks it. See {Capybara::Node::Actions#click_button} and
|
16
|
+
# {Capybara::Node::Actions#click_link} for what locator will match against for each type of element
|
18
17
|
#
|
18
|
+
# @overload click_link_or_button([locator], **options)
|
19
|
+
# @macro waiting_behavior
|
19
20
|
# @param [String] locator See {Capybara::Node::Actions#click_button} and {Capybara::Node::Actions#click_link}
|
20
21
|
#
|
21
22
|
# @return [Capybara::Node::Element] The element clicked
|
@@ -30,9 +31,8 @@ module Capybara
|
|
30
31
|
# Finds a link by id, Capybara.test_id attribute, text or title and clicks it. Also looks at image
|
31
32
|
# alt text inside the link.
|
32
33
|
#
|
33
|
-
# @
|
34
|
-
#
|
35
|
-
# @overload click_link([locator], options)
|
34
|
+
# @overload click_link([locator], **options)
|
35
|
+
# @macro waiting_behavior
|
36
36
|
# @param [String] locator text, id, Capybara.test_id attribute, title or nested image's alt attribute
|
37
37
|
# @param options See {Capybara::Node::Finders#find_link}
|
38
38
|
#
|
@@ -48,9 +48,8 @@ module Capybara
|
|
48
48
|
# \<button> element. All buttons can be found by their id, Capybara.test_id attribute, value, or title. \<button> elements can also be found
|
49
49
|
# by their text content, and image \<input> elements by their alt attribute
|
50
50
|
#
|
51
|
-
# @macro waiting_behavior
|
52
|
-
#
|
53
51
|
# @overload click_button([locator], **options)
|
52
|
+
# @macro waiting_behavior
|
54
53
|
# @param [String] locator Which button to find
|
55
54
|
# @param options See {Capybara::Node::Finders#find_button}
|
56
55
|
# @return [Capybara::Node::Element] The element clicked
|
@@ -78,10 +77,10 @@ module Capybara
|
|
78
77
|
# @macro waiting_behavior
|
79
78
|
# @option options [String] currently_with The current value property of the field to fill in
|
80
79
|
# @option options [Boolean] multiple Match fields that can have multiple values?
|
81
|
-
# @option options [String] id Match fields that match the id attribute
|
80
|
+
# @option options [String, Regexp] id Match fields that match the id attribute
|
82
81
|
# @option options [String] name Match fields that match the name attribute
|
83
82
|
# @option options [String] placeholder Match fields that match the placeholder attribute
|
84
|
-
# @option options [String, Array<String
|
83
|
+
# @option options [String, Array<String>, Regexp] class Match fields that match the class(es) provided
|
85
84
|
# @option options [Hash] fill_options Driver specific options regarding how to fill fields (Defaults come from Capybara.default_set_options)
|
86
85
|
#
|
87
86
|
# @return [Capybara::Node::Element] The element filled_in
|
@@ -110,9 +109,9 @@ module Capybara
|
|
110
109
|
# @param [String] locator Which radio button to choose
|
111
110
|
#
|
112
111
|
# @option options [String] option Value of the radio_button to choose
|
113
|
-
# @option options [String] id Match fields that match the id attribute
|
112
|
+
# @option options [String, Regexp] id Match fields that match the id attribute
|
114
113
|
# @option options [String] name Match fields that match the name attribute
|
115
|
-
# @option options [String, Array<String
|
114
|
+
# @option options [String, Array<String>, Regexp] class Match fields that match the class(es) provided
|
116
115
|
# @macro waiting_behavior
|
117
116
|
# @macro label_click
|
118
117
|
#
|
@@ -138,9 +137,9 @@ module Capybara
|
|
138
137
|
# @param [String] locator Which check box to check
|
139
138
|
#
|
140
139
|
# @option options [String] option Value of the checkbox to select
|
141
|
-
# @option options [String] id Match fields that match the id attribute
|
140
|
+
# @option options [String, Regexp] id Match fields that match the id attribute
|
142
141
|
# @option options [String] name Match fields that match the name attribute
|
143
|
-
# @option options [String, Array<String
|
142
|
+
# @option options [String, Array<String>, Regexp] class Match fields that match the class(es) provided
|
144
143
|
# @macro label_click
|
145
144
|
# @macro waiting_behavior
|
146
145
|
#
|
@@ -166,9 +165,9 @@ module Capybara
|
|
166
165
|
# @param [String] locator Which check box to uncheck
|
167
166
|
#
|
168
167
|
# @option options [String] option Value of the checkbox to deselect
|
169
|
-
# @option options [String] id Match fields that match the id attribute
|
168
|
+
# @option options [String, Regexp] id Match fields that match the id attribute
|
170
169
|
# @option options [String] name Match fields that match the name attribute
|
171
|
-
# @option options [String, Array<String
|
170
|
+
# @option options [String, Array<String>, Regexp] class Match fields that match the class(es) provided
|
172
171
|
# @macro label_click
|
173
172
|
# @macro waiting_behavior
|
174
173
|
#
|
@@ -188,10 +187,11 @@ module Capybara
|
|
188
187
|
#
|
189
188
|
# page.select 'March', from: 'Month'
|
190
189
|
#
|
191
|
-
# @
|
190
|
+
# @overload select(value = nil, from: nil, **options)
|
191
|
+
# @macro waiting_behavior
|
192
192
|
#
|
193
|
-
#
|
194
|
-
#
|
193
|
+
# @param value [String] Which option to select
|
194
|
+
# @param from [String] The id, Capybara.test_id atrtribute, name or label of the select box
|
195
195
|
#
|
196
196
|
# @return [Capybara::Node::Element] The option element selected
|
197
197
|
def select(value = nil, from: nil, **options)
|
@@ -212,10 +212,12 @@ module Capybara
|
|
212
212
|
#
|
213
213
|
# page.unselect 'March', from: 'Month'
|
214
214
|
#
|
215
|
-
# @
|
215
|
+
# @overload unselect(value = nil, from: nil, **options)
|
216
|
+
# @macro waiting_behavior
|
217
|
+
#
|
218
|
+
# @param value [String] Which option to unselect
|
219
|
+
# @param from [String] The id, Capybara.test_id attribute, name or label of the select box
|
216
220
|
#
|
217
|
-
# @param value [String] Which option to unselect
|
218
|
-
# @param from [String] The id, Capybara.test_id attribute, name or label of the select box
|
219
221
|
#
|
220
222
|
# @return [Capybara::Node::Element] The option element unselected
|
221
223
|
def unselect(value = nil, from: nil, **options)
|
@@ -246,9 +248,9 @@ module Capybara
|
|
246
248
|
# @option options [Symbol] match (Capybara.match) The matching strategy to use (:one, :first, :prefer_exact, :smart).
|
247
249
|
# @option options [Boolean] exact (Capybara.exact) Match the exact label name/contents or accept a partial match.
|
248
250
|
# @option options [Boolean] multiple Match field which allows multiple file selection
|
249
|
-
# @option options [String] id Match fields that match the id attribute
|
251
|
+
# @option options [String, Regexp] id Match fields that match the id attribute
|
250
252
|
# @option options [String] name Match fields that match the name attribute
|
251
|
-
# @option options [String, Array<String
|
253
|
+
# @option options [String, Array<String>, Regexp] class Match fields that match the class(es) provided
|
252
254
|
# @option options [true, Hash] make_visible 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)
|
253
255
|
#
|
254
256
|
# @return [Capybara::Node::Element] The file field element
|
@@ -320,7 +322,8 @@ module Capybara
|
|
320
322
|
rescue StandardError # rubocop:disable Lint/HandleExceptions swallow extra errors
|
321
323
|
end
|
322
324
|
|
323
|
-
def _check_with_label(selector, checked, locator,
|
325
|
+
def _check_with_label(selector, checked, locator,
|
326
|
+
allow_label_click: session_options.automatic_label_click, **options)
|
324
327
|
options[:allow_self] = true if locator.nil?
|
325
328
|
|
326
329
|
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
data/lib/capybara/node/base.rb
CHANGED
@@ -73,9 +73,10 @@ module Capybara
|
|
73
73
|
# @return [Object] The result of the given block
|
74
74
|
# @raise [Capybara::FrozenInTime] If the return value of `Time.now` appears stuck
|
75
75
|
#
|
76
|
-
def synchronize(seconds =
|
76
|
+
def synchronize(seconds = nil, errors: nil)
|
77
77
|
return yield if session.synchronized
|
78
78
|
|
79
|
+
seconds = session_options.default_max_wait_time if seconds.nil?
|
79
80
|
session.synchronized = true
|
80
81
|
timer = Capybara::Helpers.timer(expire_in: seconds)
|
81
82
|
begin
|
@@ -17,7 +17,9 @@ module Capybara
|
|
17
17
|
# @return [true]
|
18
18
|
#
|
19
19
|
def assert_title(title, **options)
|
20
|
-
_verify_title(title, options)
|
20
|
+
_verify_title(title, options) do |query|
|
21
|
+
raise Capybara::ExpectationNotMet, query.failure_message unless query.resolves_for?(self)
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
25
|
##
|
@@ -28,7 +30,9 @@ module Capybara
|
|
28
30
|
# @return [true]
|
29
31
|
#
|
30
32
|
def assert_no_title(title, **options)
|
31
|
-
_verify_title(title, options)
|
33
|
+
_verify_title(title, options) do |query|
|
34
|
+
raise Capybara::ExpectationNotMet, query.negative_failure_message if query.resolves_for?(self)
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
38
|
##
|
@@ -125,9 +125,9 @@ module Capybara
|
|
125
125
|
# Select this node if is an option element inside a select tag
|
126
126
|
#
|
127
127
|
# @return [Capybara::Node::Element] The element
|
128
|
-
def select_option
|
128
|
+
def select_option(wait: nil)
|
129
129
|
warn "Attempt to select disabled option: #{value || text}" if disabled?
|
130
|
-
synchronize { base.select_option }
|
130
|
+
synchronize(wait) { base.select_option }
|
131
131
|
self
|
132
132
|
end
|
133
133
|
|
@@ -136,8 +136,8 @@ module Capybara
|
|
136
136
|
# Unselect this node if is an option element inside a multiple select tag
|
137
137
|
#
|
138
138
|
# @return [Capybara::Node::Element] The element
|
139
|
-
def unselect_option
|
140
|
-
synchronize { base.unselect_option }
|
139
|
+
def unselect_option(wait: nil)
|
140
|
+
synchronize(wait) { base.unselect_option }
|
141
141
|
self
|
142
142
|
end
|
143
143
|
|
@@ -152,8 +152,8 @@ module Capybara
|
|
152
152
|
# @option offset [Integer] x X coordinate to offset the click location from the top left corner of the element
|
153
153
|
# @option offset [Integer] y Y coordinate to offset the click location from the top left corner of the element
|
154
154
|
# @return [Capybara::Node::Element] The element
|
155
|
-
def click(*keys, **offset)
|
156
|
-
synchronize { base.click(keys, offset) }
|
155
|
+
def click(*keys, wait: nil, **offset)
|
156
|
+
synchronize(wait) { base.click(keys, offset) }
|
157
157
|
self
|
158
158
|
end
|
159
159
|
|
@@ -163,8 +163,8 @@ module Capybara
|
|
163
163
|
#
|
164
164
|
# @macro click_modifiers
|
165
165
|
# @return [Capybara::Node::Element] The element
|
166
|
-
def right_click(*keys, **offset)
|
167
|
-
synchronize { base.right_click(keys, offset) }
|
166
|
+
def right_click(*keys, wait: nil, **offset)
|
167
|
+
synchronize(wait) { base.right_click(keys, offset) }
|
168
168
|
self
|
169
169
|
end
|
170
170
|
|
@@ -174,8 +174,8 @@ module Capybara
|
|
174
174
|
#
|
175
175
|
# @macro click_modifiers
|
176
176
|
# @return [Capybara::Node::Element] The element
|
177
|
-
def double_click(*keys, **offset)
|
178
|
-
synchronize { base.double_click(keys, offset) }
|
177
|
+
def double_click(*keys, wait: nil, **offset)
|
178
|
+
synchronize(wait) { base.double_click(keys, offset) }
|
179
179
|
self
|
180
180
|
end
|
181
181
|
|
@@ -9,15 +9,15 @@ module Capybara
|
|
9
9
|
# is not found.
|
10
10
|
#
|
11
11
|
# @!macro waiting_behavior
|
12
|
-
# If the driver is capable of executing JavaScript,
|
12
|
+
# If the driver is capable of executing JavaScript, this method will wait for a set amount of time
|
13
13
|
# and continuously retry finding the element until either the element is found or the time
|
14
14
|
# expires. The length of time +find+ will wait is controlled through {Capybara.default_max_wait_time}
|
15
15
|
# and defaults to 2 seconds.
|
16
16
|
# @option options [false, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear.
|
17
17
|
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
18
|
+
# page.find('#foo').find('.bar')
|
19
|
+
# page.find(:xpath, './/div[contains(., "bar")]')
|
20
|
+
# page.find('li', text: 'Quox').click_link('Delete')
|
21
21
|
#
|
22
22
|
# @param (see Capybara::Node::Finders#all)
|
23
23
|
#
|
@@ -37,7 +37,6 @@ module Capybara
|
|
37
37
|
# + If you need to check for existence of a class name that starts with ! then prefix with !!
|
38
38
|
# + ```class:['a', '!b', '!!!c'] # limit to elements with class 'a' and '!c' but not class 'b'```
|
39
39
|
# @option options [Boolean] exact Control whether `is` expressions in the given XPath match exactly or partially
|
40
|
-
# @option options [Integer, false] wait (Capybara.default_max_wait_time) The time to wait for matching elements to become available
|
41
40
|
# @option options [Symbol] match The matching strategy to use.
|
42
41
|
#
|
43
42
|
# @return [Capybara::Node::Element] The found element
|
@@ -63,7 +62,7 @@ module Capybara
|
|
63
62
|
#
|
64
63
|
# @macro waiting_behavior
|
65
64
|
#
|
66
|
-
# @option options [
|
65
|
+
# @option options [Symbol] match The matching strategy to use.
|
67
66
|
#
|
68
67
|
# @return [Capybara::Node::Element] The found element
|
69
68
|
# @raise [Capybara::ElementNotFound] If the element can't be found before time expires
|
@@ -89,7 +88,7 @@ module Capybara
|
|
89
88
|
#
|
90
89
|
# @macro waiting_behavior
|
91
90
|
#
|
92
|
-
# @option options [
|
91
|
+
# @option options [Symbol] match The matching strategy to use.
|
93
92
|
#
|
94
93
|
# @return [Capybara::Node::Element] The found element
|
95
94
|
# @raise [Capybara::ElementNotFound] If the element can't be found before time expires
|
@@ -119,10 +118,10 @@ module Capybara
|
|
119
118
|
# @option options [String, Regexp] with Value of field to match on
|
120
119
|
# @option options [String] type Type of field to match on
|
121
120
|
# @option options [Boolean] multiple Match fields that can have multiple values?
|
122
|
-
# @option options [String] id Match fields that match the id attribute
|
121
|
+
# @option options [String, Regexp] id Match fields that match the id attribute
|
123
122
|
# @option options [String] name Match fields that match the name attribute
|
124
123
|
# @option options [String] placeholder Match fields that match the placeholder attribute
|
125
|
-
# @option options [String, Array<String
|
124
|
+
# @option options [String, Array<String>, Regexp] class Match fields that match the class(es) passed
|
126
125
|
# @return [Capybara::Node::Element] The found element
|
127
126
|
#
|
128
127
|
|
@@ -140,10 +139,10 @@ module Capybara
|
|
140
139
|
# @macro waiting_behavior
|
141
140
|
#
|
142
141
|
# @option options [String,Regexp,nil] href Value to match against the links href, if nil finds link placeholders (<a> elements with no href attribute)
|
143
|
-
# @option options [String] id Match links with the id provided
|
142
|
+
# @option options [String, Regexp] id Match links with the id provided
|
144
143
|
# @option options [String] title Match links with the title provided
|
145
144
|
# @option options [String] alt Match links with a contained img element whose alt matches
|
146
|
-
# @option options [String, Array<String
|
145
|
+
# @option options [String, Array<String>, Regexp] class Match links that match the class(es) provided
|
147
146
|
# @return [Capybara::Node::Element] The found element
|
148
147
|
#
|
149
148
|
def find_link(locator = nil, **options, &optional_filter_block)
|
@@ -168,10 +167,10 @@ module Capybara
|
|
168
167
|
# * true - only finds a disabled button
|
169
168
|
# * false - only finds an enabled button
|
170
169
|
# * :all - finds either an enabled or disabled button
|
171
|
-
# @option options [String] id Match buttons with the id provided
|
170
|
+
# @option options [String, Regexp] id Match buttons with the id provided
|
172
171
|
# @option options [String] title Match buttons with the title provided
|
173
172
|
# @option options [String] value Match buttons with the value provided
|
174
|
-
# @option options [String, Array<String
|
173
|
+
# @option options [String, Array<String>, Regexp] class Match buttons that match the class(es) provided
|
175
174
|
# @return [Capybara::Node::Element] The found element
|
176
175
|
#
|
177
176
|
def find_button(locator = nil, **options, &optional_filter_block)
|
@@ -276,7 +275,7 @@ module Capybara
|
|
276
275
|
# element is found, or `nil` if the provided count options allow for empty results.
|
277
276
|
#
|
278
277
|
# @overload first([kind], locator, options)
|
279
|
-
# @param [
|
278
|
+
# @param [Symbol] kind The type of selector
|
280
279
|
# @param [String] locator The selector
|
281
280
|
# @param [Hash] options Additional options; see {#all}
|
282
281
|
# @return [Capybara::Node::Element] The found element or nil
|