capybara 3.15.0 → 3.17.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 +39 -0
- data/README.md +3 -3
- data/lib/capybara/config.rb +1 -2
- data/lib/capybara/helpers.rb +1 -1
- data/lib/capybara/node/actions.rb +6 -6
- data/lib/capybara/node/base.rb +5 -5
- data/lib/capybara/node/element.rb +5 -5
- data/lib/capybara/node/finders.rb +7 -5
- data/lib/capybara/node/simple.rb +3 -2
- data/lib/capybara/queries/base_query.rb +1 -1
- data/lib/capybara/queries/selector_query.rb +7 -7
- data/lib/capybara/queries/style_query.rb +1 -1
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/registrations/drivers.rb +36 -0
- data/lib/capybara/registrations/servers.rb +38 -0
- data/lib/capybara/result.rb +2 -2
- data/lib/capybara/rspec/matcher_proxies.rb +2 -2
- data/lib/capybara/rspec/matchers/base.rb +2 -2
- data/lib/capybara/rspec/matchers.rb +1 -1
- data/lib/capybara/selector/css.rb +3 -3
- data/lib/capybara/selector/filters/base.rb +1 -1
- data/lib/capybara/selector/selector.rb +1 -0
- data/lib/capybara/selector/xpath_extensions.rb +8 -0
- data/lib/capybara/selector.rb +117 -102
- data/lib/capybara/selenium/driver.rb +97 -48
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +16 -4
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +23 -0
- data/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +5 -0
- data/lib/capybara/selenium/driver_specializations/safari_driver.rb +13 -0
- data/lib/capybara/selenium/extensions/find.rb +48 -37
- data/lib/capybara/selenium/extensions/html5_drag.rb +3 -1
- data/lib/capybara/selenium/logger_suppressor.rb +29 -0
- data/lib/capybara/selenium/node.rb +22 -8
- data/lib/capybara/selenium/nodes/chrome_node.rb +8 -4
- data/lib/capybara/selenium/patches/persistent_client.rb +20 -0
- data/lib/capybara/server/animation_disabler.rb +1 -1
- data/lib/capybara/server/checker.rb +1 -1
- data/lib/capybara/server/middleware.rb +3 -3
- data/lib/capybara/session/config.rb +2 -8
- data/lib/capybara/session.rb +9 -5
- data/lib/capybara/spec/session/attach_file_spec.rb +1 -1
- data/lib/capybara/spec/session/check_spec.rb +4 -4
- data/lib/capybara/spec/session/choose_spec.rb +2 -2
- data/lib/capybara/spec/session/click_button_spec.rb +28 -1
- data/lib/capybara/spec/session/fill_in_spec.rb +2 -2
- data/lib/capybara/spec/session/find_spec.rb +1 -1
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +14 -1
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +12 -1
- data/lib/capybara/spec/session/has_css_spec.rb +9 -2
- data/lib/capybara/spec/session/has_table_spec.rb +4 -4
- data/lib/capybara/spec/session/node_spec.rb +18 -6
- data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
- data/lib/capybara/spec/session/unselect_spec.rb +1 -1
- data/lib/capybara/spec/spec_helper.rb +1 -1
- data/lib/capybara/spec/views/frame_child.erb +2 -1
- data/lib/capybara/spec/views/react.erb +45 -0
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +1 -1
- data/lib/capybara.rb +2 -70
- data/spec/minitest_spec_spec.rb +1 -1
- data/spec/result_spec.rb +10 -6
- data/spec/rspec/shared_spec_matchers.rb +8 -4
- data/spec/sauce_spec_chrome.rb +42 -0
- data/spec/selector_spec.rb +4 -0
- data/spec/selenium_spec_safari.rb +2 -3
- data/spec/session_spec.rb +7 -0
- data/spec/shared_selenium_session.rb +14 -12
- data/spec/spec_helper.rb +2 -1
- metadata +37 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e077e28912ed7973882a0394db7eb44c493b0546175f81ef6f15c8ad1ee564c1
|
|
4
|
+
data.tar.gz: 6efae1078877ffe1578dc28d83f6d8df338dc01a162214c5b3aa3bd625c6a426
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48d7420e5621c0dafbff830bfa56aba6ccf1d171d9efd0081f30f95f0cc538fa655d6fd5bef5525d13da573f51993f443f89b20af9b2241e4b9194b6ca3d2ae1
|
|
7
|
+
data.tar.gz: e7470806d56a47cbb6a2b12690816cc0cb569d26032ccae32ad2d832f356d59235f156651a8422ba70259021f9e47a81ad43f4d3e97612891e7e98c6eb1c857e
|
data/History.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
# Version 3.17.0
|
|
2
|
+
Release date: 2019-04-18
|
|
3
|
+
|
|
4
|
+
### Added
|
|
5
|
+
|
|
6
|
+
* Initial support for selenium-webdriver 4.0.0.alpha1
|
|
7
|
+
* :button selector will now also match on `name` attribute
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
* Suppress warnings generated by using selenium-webdriver 3.141.5926
|
|
12
|
+
* Mask Appium issue with finder visibility optimizations (non-optimal)
|
|
13
|
+
|
|
14
|
+
# Version 3.16.2
|
|
15
|
+
Release date: 2019-04-10
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
* Fix Session#quit resetting of memoized document
|
|
20
|
+
|
|
21
|
+
# Version 3.16.1
|
|
22
|
+
Release date: 2019-03-30
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
* Fix potential 'uninitialized constant' error when using the :selenium_chrome driver [jeffclemens-ab]
|
|
27
|
+
|
|
28
|
+
# Version 3.16
|
|
29
|
+
Release date: 2019-03-28
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
* Ruby 2.4.0+ is now required
|
|
34
|
+
* Selenium driver now defaults to using a persistent http client connection
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
* :wait option in predicates now accepts `true` to selectively override when `Capybara.predicates_wait == false`
|
|
39
|
+
|
|
1
40
|
# Version 3.15
|
|
2
41
|
Release date: 2019-03-19
|
|
3
42
|
|
data/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
7
7
|
[](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 3.
|
|
9
|
+
**Note** You are viewing the README for the 3.17.x version of Capybara.
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
Capybara helps you test web applications by simulating how a real user would
|
|
@@ -76,7 +76,7 @@ GitHub): http://groups.google.com/group/ruby-capybara
|
|
|
76
76
|
|
|
77
77
|
## <a name="setup"></a>Setup
|
|
78
78
|
|
|
79
|
-
Capybara requires Ruby 2.
|
|
79
|
+
Capybara requires Ruby 2.4.0 or later. To install, add this line to your
|
|
80
80
|
`Gemfile` and run `bundle install`:
|
|
81
81
|
|
|
82
82
|
```ruby
|
|
@@ -419,7 +419,7 @@ teamcapybara repo once completely stable.
|
|
|
419
419
|
|
|
420
420
|
### <a name="capybara-webkit"></a>Capybara-webkit
|
|
421
421
|
|
|
422
|
-
Note: `capybara-webkit` depends on QtWebkit which went
|
|
422
|
+
Note: `capybara-webkit` depends on QtWebkit which went end-of-life quite some time ago. There has been an attempt to revive the project but `capybara-webkit` is not yet (as far as I know) compatible with the revived version of QtWebKit (could be a good open source 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.
|
|
423
423
|
|
|
424
424
|
The [capybara-webkit driver](https://github.com/thoughtbot/capybara-webkit) is for true headless
|
|
425
425
|
testing. It uses QtWebKit to start a rendering engine process. It can execute JavaScript as well.
|
data/lib/capybara/config.rb
CHANGED
|
@@ -7,8 +7,7 @@ module Capybara
|
|
|
7
7
|
class Config
|
|
8
8
|
extend Forwardable
|
|
9
9
|
|
|
10
|
-
OPTIONS = %i[app reuse_server threadsafe
|
|
11
|
-
default_driver javascript_driver allow_gumbo].freeze
|
|
10
|
+
OPTIONS = %i[app reuse_server threadsafe server default_driver javascript_driver allow_gumbo].freeze
|
|
12
11
|
|
|
13
12
|
attr_accessor :app
|
|
14
13
|
attr_reader :reuse_server, :threadsafe
|
data/lib/capybara/helpers.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Capybara
|
|
|
8
8
|
# and continuously retry finding the element until either the element is found or the time
|
|
9
9
|
# expires. The length of time +find+ will wait is controlled through {Capybara.default_max_wait_time}
|
|
10
10
|
#
|
|
11
|
-
# @option options [false, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear.
|
|
11
|
+
# @option options [false, true, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear.
|
|
12
12
|
|
|
13
13
|
##
|
|
14
14
|
#
|
|
@@ -45,7 +45,7 @@ module Capybara
|
|
|
45
45
|
#
|
|
46
46
|
# Finds a button on the page and clicks it.
|
|
47
47
|
# This can be any \<input> element of type submit, reset, image, button or it can be a
|
|
48
|
-
# \<button> element. All buttons can be found by their id, Capybara.test_id attribute, value, or title. \<button> elements can also be found
|
|
48
|
+
# \<button> element. All buttons can be found by their id, name, 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
51
|
# @overload click_button([locator], **options)
|
|
@@ -300,7 +300,7 @@ module Capybara
|
|
|
300
300
|
synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
|
|
301
301
|
begin
|
|
302
302
|
find(:select, from, options)
|
|
303
|
-
rescue Capybara::ElementNotFound => select_error
|
|
303
|
+
rescue Capybara::ElementNotFound => select_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
|
304
304
|
raise if %i[selected with_selected multiple].any? { |option| options.key?(option) }
|
|
305
305
|
|
|
306
306
|
begin
|
|
@@ -356,14 +356,14 @@ module Capybara
|
|
|
356
356
|
begin
|
|
357
357
|
el = find(selector, locator, options)
|
|
358
358
|
el.set(checked)
|
|
359
|
-
rescue StandardError =>
|
|
360
|
-
raise unless allow_label_click && catch_error?(
|
|
359
|
+
rescue StandardError => e
|
|
360
|
+
raise unless allow_label_click && catch_error?(e)
|
|
361
361
|
|
|
362
362
|
begin
|
|
363
363
|
el ||= find(selector, locator, options.merge(visible: :all))
|
|
364
364
|
el.session.find(:label, for: el, visible: true).click unless el.checked? == checked
|
|
365
365
|
rescue StandardError # swallow extra errors - raise original
|
|
366
|
-
raise
|
|
366
|
+
raise e
|
|
367
367
|
end
|
|
368
368
|
end
|
|
369
369
|
end
|
data/lib/capybara/node/base.rb
CHANGED
|
@@ -76,24 +76,24 @@ module Capybara
|
|
|
76
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
|
|
79
|
+
seconds = session_options.default_max_wait_time if [nil, true].include? seconds
|
|
80
80
|
session.synchronized = true
|
|
81
81
|
timer = Capybara::Helpers.timer(expire_in: seconds)
|
|
82
82
|
begin
|
|
83
83
|
yield
|
|
84
|
-
rescue StandardError =>
|
|
84
|
+
rescue StandardError => e
|
|
85
85
|
session.raise_server_error!
|
|
86
|
-
raise
|
|
86
|
+
raise e unless catch_error?(e, errors)
|
|
87
87
|
|
|
88
88
|
if driver.wait?
|
|
89
|
-
raise
|
|
89
|
+
raise e if timer.expired?
|
|
90
90
|
|
|
91
91
|
sleep(0.01)
|
|
92
92
|
reload if session_options.automatic_reload
|
|
93
93
|
else
|
|
94
94
|
old_base = @base
|
|
95
95
|
reload if session_options.automatic_reload
|
|
96
|
-
raise
|
|
96
|
+
raise e if old_base == @base
|
|
97
97
|
end
|
|
98
98
|
retry
|
|
99
99
|
ensure
|
|
@@ -87,11 +87,11 @@ module Capybara
|
|
|
87
87
|
|
|
88
88
|
begin
|
|
89
89
|
synchronize { base.style(styles) }
|
|
90
|
-
rescue NotImplementedError =>
|
|
90
|
+
rescue NotImplementedError => e
|
|
91
91
|
begin
|
|
92
92
|
evaluate_script(STYLE_SCRIPT, *styles)
|
|
93
93
|
rescue Capybara::NotSupportedByDriverError
|
|
94
|
-
raise
|
|
94
|
+
raise e
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
end
|
|
@@ -113,7 +113,7 @@ module Capybara
|
|
|
113
113
|
#
|
|
114
114
|
# @return [Capybara::Node::Element] The element
|
|
115
115
|
def set(value, **options)
|
|
116
|
-
raise Capybara::ReadOnlyElementError, "Attempt to set readonly element with value: #{value}" if readonly?
|
|
116
|
+
raise Capybara::ReadOnlyElementError, "Attempt to set readonly element with value: #{value}" if ENV['CAPYBARA_THOROUGH'] && readonly?
|
|
117
117
|
|
|
118
118
|
options = session_options.default_set_options.to_h.merge(options)
|
|
119
119
|
synchronize { base.set(value, options) }
|
|
@@ -469,8 +469,8 @@ module Capybara
|
|
|
469
469
|
begin
|
|
470
470
|
reloaded = query_scope.reload.first(@query.name, @query.locator, @query.options)
|
|
471
471
|
@base = reloaded.base if reloaded
|
|
472
|
-
rescue StandardError =>
|
|
473
|
-
raise
|
|
472
|
+
rescue StandardError => e
|
|
473
|
+
raise e unless catch_error?(e)
|
|
474
474
|
end
|
|
475
475
|
end
|
|
476
476
|
self
|
|
@@ -13,7 +13,7 @@ module Capybara
|
|
|
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
|
-
# @option options [false, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear.
|
|
16
|
+
# @option options [false, true, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear.
|
|
17
17
|
#
|
|
18
18
|
# page.find('#foo').find('.bar')
|
|
19
19
|
# page.find(:xpath, './/div[contains(., "bar")]')
|
|
@@ -154,11 +154,11 @@ module Capybara
|
|
|
154
154
|
#
|
|
155
155
|
# Find a button on the page.
|
|
156
156
|
# This can be any \<input> element of type submit, reset, image, button or it can be a
|
|
157
|
-
# \<button> element. All buttons can be found by their id, Capbyara.test_id attribute, value, or title. \<button> elements can also be found
|
|
157
|
+
# \<button> element. All buttons can be found by their id, name, Capbyara.test_id attribute, value, or title. \<button> elements can also be found
|
|
158
158
|
# by their text content, and image \<input> elements by their alt attribute
|
|
159
159
|
#
|
|
160
160
|
# @overload find_button([locator], **options)
|
|
161
|
-
# @param [String] locator id, Capybara.test_id attribute, value, title, text content, alt of image
|
|
161
|
+
# @param [String] locator id, name, Capybara.test_id attribute, value, title, text content, alt of image
|
|
162
162
|
#
|
|
163
163
|
# @overload find_button(**options)
|
|
164
164
|
#
|
|
@@ -169,8 +169,9 @@ module Capybara
|
|
|
169
169
|
# * false - only finds an enabled button
|
|
170
170
|
# * :all - finds either an enabled or disabled button
|
|
171
171
|
# @option options [String, Regexp] id Match buttons with the id provided
|
|
172
|
-
# @option options [String]
|
|
173
|
-
# @option options [String]
|
|
172
|
+
# @option options [String] name Match buttons with the name provided
|
|
173
|
+
# @option options [String] title Match buttons with the title provided
|
|
174
|
+
# @option options [String] value Match buttons with the value provided
|
|
174
175
|
# @option options [String, Array<String>, Regexp] class Match buttons that match the class(es) provided
|
|
175
176
|
# @return [Capybara::Node::Element] The found element
|
|
176
177
|
#
|
|
@@ -241,6 +242,7 @@ module Capybara
|
|
|
241
242
|
# @option options [Integer] maximum Maximum number of matches that are expected to be found
|
|
242
243
|
# @option options [Integer] minimum Minimum number of matches that are expected to be found
|
|
243
244
|
# @option options [Range] between Number of matches found must be within the given range
|
|
245
|
+
# @option options [false, true, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear.
|
|
244
246
|
# @overload all([kind = Capybara.default_selector], locator = nil, **options)
|
|
245
247
|
# @overload all([kind = Capybara.default_selector], locator = nil, **options, &filter_block)
|
|
246
248
|
# @yieldparam element [Capybara::Node::Element] The element being considered for inclusion in the results
|
data/lib/capybara/node/simple.rb
CHANGED
|
@@ -107,7 +107,7 @@ module Capybara
|
|
|
107
107
|
!find_xpath(VISIBILITY_XPATH)
|
|
108
108
|
else
|
|
109
109
|
# No need for an xpath if only checking the current element
|
|
110
|
-
!(native.key?('hidden') || (
|
|
110
|
+
!(native.key?('hidden') || (/display:\s?none/.match? native[:style]) || %w[script head].include?(tag_name))
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
|
|
@@ -127,7 +127,8 @@ module Capybara
|
|
|
127
127
|
#
|
|
128
128
|
# @return [Boolean] Whether the element is disabled
|
|
129
129
|
def disabled?
|
|
130
|
-
native.has_attribute?('disabled')
|
|
130
|
+
native.has_attribute?('disabled') &&
|
|
131
|
+
%w[button input select textarea optgroup option menuitem fieldset].include?(tag_name)
|
|
131
132
|
end
|
|
132
133
|
|
|
133
134
|
##
|
|
@@ -98,7 +98,7 @@ module Capybara
|
|
|
98
98
|
|
|
99
99
|
invalid_names = invalid_keys.map(&:inspect).join(', ')
|
|
100
100
|
valid_names = valid_keys.map(&:inspect).join(', ')
|
|
101
|
-
raise ArgumentError, "
|
|
101
|
+
raise ArgumentError, "Invalid option(s) #{invalid_names}, should be one of #{valid_names}"
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
end
|
|
@@ -83,7 +83,7 @@ module Capybara
|
|
|
83
83
|
matches_system_filters?(node) &&
|
|
84
84
|
matches_node_filters?(node, node_filter_errors) &&
|
|
85
85
|
matches_filter_block?(node)
|
|
86
|
-
rescue *(node.respond_to?(:session) ? node.session.driver.invalid_element_errors : [])
|
|
86
|
+
rescue *(node.respond_to?(:session) ? node.session.driver.invalid_element_errors : []) # rubocop:disable Naming/RescuedExceptionsVariableName
|
|
87
87
|
false
|
|
88
88
|
end
|
|
89
89
|
|
|
@@ -271,7 +271,7 @@ module Capybara
|
|
|
271
271
|
|
|
272
272
|
def assert_valid_keys
|
|
273
273
|
unless VALID_MATCH.include?(match)
|
|
274
|
-
raise ArgumentError, "
|
|
274
|
+
raise ArgumentError, "Invalid option #{match.inspect} for :match, should be one of #{VALID_MATCH.map(&:inspect).join(', ')}"
|
|
275
275
|
end
|
|
276
276
|
|
|
277
277
|
unhandled_options = @options.keys.reject do |option_name|
|
|
@@ -284,7 +284,7 @@ module Capybara
|
|
|
284
284
|
|
|
285
285
|
invalid_names = unhandled_options.map(&:inspect).join(', ')
|
|
286
286
|
valid_names = (valid_keys - [:allow_self]).map(&:inspect).join(', ')
|
|
287
|
-
raise ArgumentError, "
|
|
287
|
+
raise ArgumentError, "Invalid option(s) #{invalid_names}, should be one of #{valid_names}"
|
|
288
288
|
end
|
|
289
289
|
|
|
290
290
|
def filtered_expression(expr)
|
|
@@ -368,13 +368,13 @@ module Capybara
|
|
|
368
368
|
def matches_id_filter?(node)
|
|
369
369
|
return true unless use_default_id_filter? && options[:id].is_a?(Regexp)
|
|
370
370
|
|
|
371
|
-
|
|
371
|
+
options[:id].match? node[:id]
|
|
372
372
|
end
|
|
373
373
|
|
|
374
374
|
def matches_class_filter?(node)
|
|
375
375
|
return true unless use_default_class_filter? && options[:class].is_a?(Regexp)
|
|
376
376
|
|
|
377
|
-
|
|
377
|
+
options[:class].match? node[:class]
|
|
378
378
|
end
|
|
379
379
|
|
|
380
380
|
def matches_style_filter?(node)
|
|
@@ -382,7 +382,7 @@ module Capybara
|
|
|
382
382
|
when String, nil
|
|
383
383
|
true
|
|
384
384
|
when Regexp
|
|
385
|
-
|
|
385
|
+
options[:style].match? node[:style]
|
|
386
386
|
when Hash
|
|
387
387
|
matches_style?(node, options[:style])
|
|
388
388
|
end
|
|
@@ -392,7 +392,7 @@ module Capybara
|
|
|
392
392
|
@actual_styles = node.initial_cache[:style] || node.style(*styles.keys)
|
|
393
393
|
styles.all? do |style, value|
|
|
394
394
|
if value.is_a? Regexp
|
|
395
|
-
@actual_styles[style.to_s]
|
|
395
|
+
value.match? @actual_styles[style.to_s]
|
|
396
396
|
else
|
|
397
397
|
@actual_styles[style.to_s] == value
|
|
398
398
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Capybara.register_driver :rack_test do |app|
|
|
4
|
+
Capybara::RackTest::Driver.new(app)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Capybara.register_driver :selenium do |app|
|
|
8
|
+
Capybara::Selenium::Driver.new(app)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Capybara.register_driver :selenium_headless do |app|
|
|
12
|
+
Capybara::Selenium::Driver.load_selenium
|
|
13
|
+
browser_options = ::Selenium::WebDriver::Firefox::Options.new
|
|
14
|
+
browser_options.args << '-headless'
|
|
15
|
+
Capybara::Selenium::Driver.new(app, browser: :firefox, options: browser_options)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Capybara.register_driver :selenium_chrome do |app|
|
|
19
|
+
Capybara::Selenium::Driver.load_selenium
|
|
20
|
+
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
|
21
|
+
# Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
|
|
22
|
+
opts.args << '--disable-site-isolation-trials'
|
|
23
|
+
end
|
|
24
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Capybara.register_driver :selenium_chrome_headless do |app|
|
|
28
|
+
Capybara::Selenium::Driver.load_selenium
|
|
29
|
+
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
|
30
|
+
opts.args << '--headless'
|
|
31
|
+
opts.args << '--disable-gpu' if Gem.win_platform?
|
|
32
|
+
# Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
|
|
33
|
+
opts.args << '--disable-site-isolation-trials'
|
|
34
|
+
end
|
|
35
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
|
36
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Capybara.register_server :default do |app, port, _host|
|
|
4
|
+
Capybara.run_default_server(app, port)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Capybara.register_server :webrick do |app, port, host, **options|
|
|
8
|
+
require 'rack/handler/webrick'
|
|
9
|
+
options = { Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log.new(nil, 0) }.merge(options)
|
|
10
|
+
Rack::Handler::WEBrick.run(app, options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Capybara.register_server :puma do |app, port, host, **options|
|
|
14
|
+
begin
|
|
15
|
+
require 'rack/handler/puma'
|
|
16
|
+
rescue LoadError
|
|
17
|
+
raise LoadError, 'Capybara is unable to load `puma` for its server, please add `puma` to your project or specify a different server via something like `Capybara.server = :webrick`.'
|
|
18
|
+
else
|
|
19
|
+
unless Rack::Handler::Puma.respond_to?(:config)
|
|
20
|
+
raise LoadError, 'Capybara requires `puma` version 3.8.0 or higher, please upgrade `puma` or register and specify your own server block'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
# If we just run the Puma Rack handler it installs signal handlers which prevent us from being able to interrupt tests.
|
|
24
|
+
# Therefore construct and run the Server instance ourselves.
|
|
25
|
+
# Rack::Handler::Puma.run(app, { Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false }.merge(options))
|
|
26
|
+
options = { Host: host, Port: port, Threads: '0:4', workers: 0, daemon: false }.merge(options)
|
|
27
|
+
conf = Rack::Handler::Puma.config(app, options)
|
|
28
|
+
events = conf.options[:Silent] ? ::Puma::Events.strings : ::Puma::Events.stdio
|
|
29
|
+
|
|
30
|
+
events.log 'Capybara starting Puma...'
|
|
31
|
+
events.log "* Version #{Puma::Const::PUMA_VERSION} , codename: #{Puma::Const::CODE_NAME}"
|
|
32
|
+
events.log "* Min threads: #{conf.options[:min_threads]}, max threads: #{conf.options[:max_threads]}"
|
|
33
|
+
|
|
34
|
+
Puma::Server.new(conf.app, events, conf.options).tap do |s|
|
|
35
|
+
s.binder.parse conf.options[:binds], s.events
|
|
36
|
+
s.min_threads, s.max_threads = conf.options[:min_threads], conf.options[:max_threads]
|
|
37
|
+
end.run.join
|
|
38
|
+
end
|
data/lib/capybara/result.rb
CHANGED
|
@@ -149,10 +149,10 @@ module Capybara
|
|
|
149
149
|
end
|
|
150
150
|
|
|
151
151
|
def lazy_select_elements(&block)
|
|
152
|
-
# JRuby has an issue with lazy enumerators which
|
|
152
|
+
# JRuby < 9.2.8.0 has an issue with lazy enumerators which
|
|
153
153
|
# causes a concurrency issue with network requests here
|
|
154
154
|
# https://github.com/jruby/jruby/issues/4212
|
|
155
|
-
if RUBY_PLATFORM == 'java'
|
|
155
|
+
if (RUBY_PLATFORM == 'java') && (Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('9.2.8.0'))
|
|
156
156
|
@elements.select(&block).to_enum # non-lazy evaluation
|
|
157
157
|
else
|
|
158
158
|
@elements.lazy.select(&block)
|
|
@@ -41,8 +41,8 @@ module Capybara
|
|
|
41
41
|
class WrappedElementMatcher < Base
|
|
42
42
|
def matches?(actual)
|
|
43
43
|
element_matches?(wrap(actual))
|
|
44
|
-
rescue Capybara::ExpectationNotMet =>
|
|
45
|
-
@failure_message =
|
|
44
|
+
rescue Capybara::ExpectationNotMet => e
|
|
45
|
+
@failure_message = e.message
|
|
46
46
|
false
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -107,7 +107,7 @@ module Capybara
|
|
|
107
107
|
# See {Capybara::Node::Matchers#has_unchecked_field?}
|
|
108
108
|
|
|
109
109
|
# RSpec matcher for text content
|
|
110
|
-
# See {Capybara::
|
|
110
|
+
# See {Capybara::Node::Matchers#assert_text}
|
|
111
111
|
def have_text(*args)
|
|
112
112
|
Matchers::HaveText.new(*args)
|
|
113
113
|
end
|
|
@@ -6,14 +6,14 @@ module Capybara
|
|
|
6
6
|
def self.escape(str)
|
|
7
7
|
value = str.dup
|
|
8
8
|
out = +''
|
|
9
|
-
out << value.slice!(0...1) if value
|
|
10
|
-
out << (value[0]
|
|
9
|
+
out << value.slice!(0...1) if value.match?(/^[-_]/)
|
|
10
|
+
out << (value[0].match?(NMSTART) ? value.slice!(0...1) : escape_char(value.slice!(0...1)))
|
|
11
11
|
out << value.gsub(/[^a-zA-Z0-9_-]/) { |char| escape_char char }
|
|
12
12
|
out
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def self.escape_char(char)
|
|
16
|
-
char
|
|
16
|
+
char.match?(%r{[ -/:-~]}) ? "\\#{char}" : format('\\%06x', char.ord)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def self.split(css)
|
|
@@ -59,6 +59,7 @@ module Capybara
|
|
|
59
59
|
# * Locator: Matches the id, Capybara.test_id attribute, value, or title attributes, string content of a button, or the alt attribute of an image type button or of a descendant image of a button
|
|
60
60
|
# * Filters:
|
|
61
61
|
# * :id (String, Regexp, XPath::Expression) — Matches the id attribute
|
|
62
|
+
# * :name (String) - Matches the name attribute
|
|
62
63
|
# * :title (String) — Matches the title attribute
|
|
63
64
|
# * :class (String, Array<String>, Regexp, XPath::Expression) — Matches the class(es) provided
|
|
64
65
|
# * :value (String) — Matches the value of an input button
|