capybara 3.32.2 → 3.35.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +97 -15
- data/README.md +9 -4
- data/lib/capybara.rb +18 -8
- data/lib/capybara/config.rb +4 -6
- data/lib/capybara/cucumber.rb +1 -1
- data/lib/capybara/driver/base.rb +4 -0
- data/lib/capybara/helpers.rb +25 -1
- data/lib/capybara/minitest.rb +2 -3
- data/lib/capybara/minitest/spec.rb +14 -11
- data/lib/capybara/node/actions.rb +16 -21
- data/lib/capybara/node/base.rb +6 -6
- data/lib/capybara/node/element.rb +1 -5
- data/lib/capybara/node/finders.rb +7 -6
- data/lib/capybara/node/matchers.rb +12 -12
- data/lib/capybara/node/simple.rb +5 -1
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/current_path_query.rb +14 -4
- data/lib/capybara/queries/selector_query.rb +40 -18
- data/lib/capybara/queries/sibling_query.rb +1 -1
- data/lib/capybara/queries/style_query.rb +1 -1
- data/lib/capybara/queries/text_query.rb +7 -1
- data/lib/capybara/rack_test/browser.rb +7 -3
- data/lib/capybara/rack_test/driver.rb +1 -0
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/rack_test/node.rb +1 -1
- data/lib/capybara/registration_container.rb +44 -0
- data/lib/capybara/registrations/drivers.rb +18 -12
- data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
- data/lib/capybara/registrations/servers.rb +2 -1
- data/lib/capybara/result.rb +6 -10
- data/lib/capybara/rspec.rb +2 -0
- data/lib/capybara/rspec/matcher_proxies.rb +1 -1
- data/lib/capybara/rspec/matchers.rb +7 -6
- data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
- data/lib/capybara/rspec/matchers/match_style.rb +5 -0
- data/lib/capybara/selector.rb +12 -3
- data/lib/capybara/selector/builders/css_builder.rb +1 -1
- data/lib/capybara/selector/builders/xpath_builder.rb +3 -1
- data/lib/capybara/selector/definition.rb +11 -9
- data/lib/capybara/selector/definition/button.rb +26 -14
- data/lib/capybara/selector/definition/css.rb +1 -1
- data/lib/capybara/selector/definition/datalist_input.rb +1 -1
- data/lib/capybara/selector/definition/element.rb +2 -1
- data/lib/capybara/selector/definition/fillable_field.rb +1 -1
- data/lib/capybara/selector/definition/label.rb +1 -1
- data/lib/capybara/selector/definition/link.rb +8 -0
- data/lib/capybara/selector/definition/select.rb +1 -1
- data/lib/capybara/selector/definition/table.rb +1 -1
- data/lib/capybara/selector/definition/table_row.rb +2 -2
- data/lib/capybara/selector/filter_set.rb +2 -2
- data/lib/capybara/selector/selector.rb +9 -1
- data/lib/capybara/selenium/atoms/src/isDisplayed.js +1 -1
- data/lib/capybara/selenium/driver.rb +48 -4
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +9 -11
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +9 -11
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +1 -1
- data/lib/capybara/selenium/extensions/find.rb +4 -4
- data/lib/capybara/selenium/extensions/scroll.rb +8 -10
- data/lib/capybara/selenium/logger_suppressor.rb +8 -2
- data/lib/capybara/selenium/node.rb +9 -5
- data/lib/capybara/selenium/nodes/chrome_node.rb +23 -5
- data/lib/capybara/selenium/nodes/firefox_node.rb +7 -2
- data/lib/capybara/selenium/nodes/safari_node.rb +1 -1
- data/lib/capybara/selenium/patches/atoms.rb +4 -4
- data/lib/capybara/selenium/patches/logs.rb +7 -9
- data/lib/capybara/server/animation_disabler.rb +8 -3
- data/lib/capybara/server/middleware.rb +4 -2
- data/lib/capybara/session.rb +23 -14
- data/lib/capybara/session/config.rb +3 -1
- data/lib/capybara/session/matchers.rb +11 -11
- data/lib/capybara/spec/public/test.js +13 -1
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
- data/lib/capybara/spec/session/check_spec.rb +6 -0
- data/lib/capybara/spec/session/click_button_spec.rb +11 -0
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +9 -0
- data/lib/capybara/spec/session/current_url_spec.rb +11 -1
- data/lib/capybara/spec/session/has_button_spec.rb +51 -0
- data/lib/capybara/spec/session/has_css_spec.rb +2 -1
- data/lib/capybara/spec/session/has_current_path_spec.rb +15 -2
- data/lib/capybara/spec/session/has_field_spec.rb +16 -0
- data/lib/capybara/spec/session/has_select_spec.rb +4 -4
- data/lib/capybara/spec/session/has_selector_spec.rb +4 -4
- data/lib/capybara/spec/session/has_text_spec.rb +0 -11
- data/lib/capybara/spec/session/html_spec.rb +1 -1
- data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
- data/lib/capybara/spec/session/node_spec.rb +29 -9
- data/lib/capybara/spec/session/refresh_spec.rb +2 -1
- data/lib/capybara/spec/session/save_page_spec.rb +4 -4
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/windows_spec.rb +1 -1
- data/lib/capybara/spec/spec_helper.rb +12 -12
- data/lib/capybara/spec/test_app.rb +23 -21
- data/lib/capybara/spec/views/form.erb +25 -2
- data/lib/capybara/spec/views/with_animation.erb +8 -0
- data/lib/capybara/spec/views/with_dragula.erb +3 -1
- data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
- data/lib/capybara/spec/views/with_js.erb +3 -0
- data/lib/capybara/spec/views/with_sortable_js.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +3 -7
- data/spec/basic_node_spec.rb +9 -8
- data/spec/capybara_spec.rb +1 -1
- data/spec/dsl_spec.rb +14 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
- data/spec/minitest_spec.rb +3 -2
- data/spec/rack_test_spec.rb +16 -5
- data/spec/rspec/features_spec.rb +3 -1
- data/spec/rspec/scenarios_spec.rb +4 -0
- data/spec/rspec/shared_spec_matchers.rb +61 -49
- data/spec/rspec_spec.rb +4 -0
- data/spec/selector_spec.rb +17 -2
- data/spec/selenium_spec_chrome.rb +39 -20
- data/spec/selenium_spec_chrome_remote.rb +5 -1
- data/spec/selenium_spec_firefox.rb +15 -13
- data/spec/server_spec.rb +60 -49
- data/spec/shared_selenium_session.rb +83 -1
- data/spec/spec_helper.rb +1 -1
- metadata +49 -14
- data/lib/capybara/spec/session/source_spec.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e707b56213a558121aec02091da3b9558d49231937d45c38dfaf80a2dd29b42c
|
4
|
+
data.tar.gz: c6fee456f607511bd5e2c2113f92100732c1bc317ad027f457bd762f66374f1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03f2c85d4a433acc5ae479698b568c90069019fdde4386d7a304c48563ddb2fde06912ca158505734f92879206eb74fa96043e39f8f89c74e76f1a539ed4ae7a
|
7
|
+
data.tar.gz: aa26c8230d97e0716cb65fac45a660724430ea945a4292afeeba8ef7f49915b8aefb3eda0a592177c6bae8689debab283ea37a7594f01c46a0f453d4954cac54
|
data/History.md
CHANGED
@@ -1,10 +1,92 @@
|
|
1
|
+
# Version 3.35.2
|
2
|
+
Release date: 2020-01-29
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
|
6
|
+
* Selenium deprecation suppressor with Selenium 3.x
|
7
|
+
|
8
|
+
# Version 3.35.1
|
9
|
+
Release date: 2020-01-26
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
* Default chrome driver registrations use chrome - Issue #2442 [Yuriy Alekseyev]
|
14
|
+
* 'Capybara.test_id' usage with the :button selector - Issue #2443
|
15
|
+
|
16
|
+
# Version 3.35.0
|
17
|
+
Release date: 2020-01-25
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
* Support Regexp matching for individual class names in :class filter passed an Array
|
22
|
+
* Animation disabler now supports JQuery animation disabling when JQuery loaded from body [Chien-Wei Huang]
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
|
26
|
+
* :button selector type use with `enable_aria_role` [Sean Doyle]
|
27
|
+
* <label> elements don't associate with aria-role buttons
|
28
|
+
* Ignore Selenium::WebDriver::Error::InvalidSessionIdError when quitting driver [Robin Daugherty]
|
29
|
+
* Firefox: Don't click input when sending keys if already focused
|
30
|
+
* Miscellaneous issues with selenium-webdriver 4.0.0.alphas
|
31
|
+
* Nil return error in node details optimizations
|
32
|
+
* Animation disabler now inserts XHTML compliant content [Dale Morgan]
|
33
|
+
|
34
|
+
# Version 3.34.0
|
35
|
+
Release date: 2020-11-26
|
36
|
+
|
37
|
+
### Added
|
38
|
+
|
39
|
+
* Ability to fill in with emoji when using Chrome with selenium driver (Firefox already worked)
|
40
|
+
* Current path assertions/expectations accept optional filter block
|
41
|
+
* Animation disabler now specifies `scroll-behavior: auto;` [Nathan Broadbent]
|
42
|
+
* :button selector can now find elements by label text [Sean Doyle]
|
43
|
+
* `Session#send_keys` to send keys to the current element with focus in drivers that support the
|
44
|
+
concept of a current element [Sean Doyle]
|
45
|
+
|
46
|
+
### Changed
|
47
|
+
|
48
|
+
* Text query validates the type parameter to prevent undefined behavior
|
49
|
+
|
50
|
+
### Fixed
|
51
|
+
|
52
|
+
* racktest driver better handles fragments and redirection to urls that include fragments
|
53
|
+
* Don't error when attempting to get XPath location of a shadow element
|
54
|
+
* Missing `readonly?` added to Node::Simple
|
55
|
+
* Selenium version detection when loaded via alternate method [Joel Hawksley]
|
56
|
+
* Connection count issue if REQUEST_URI value changed by app [Blake Williams]
|
57
|
+
* Maintain URI fragment when redirecting in rack-test driver
|
58
|
+
* Text query error message [Wojciech Wnętrzak]
|
59
|
+
* Checking a checkbox/radio button with `allow_label_click` now works if there are multiple labels (Issue #2421)
|
60
|
+
* `drop` with `Pathname` (Issue #2424)[Máximo Mussini]
|
61
|
+
|
62
|
+
# Version 3.33.0
|
63
|
+
Release date: 2020-06-21
|
64
|
+
|
65
|
+
### Added
|
66
|
+
|
67
|
+
* Block passed to `within_session` now receives the new and old session
|
68
|
+
* Support for aria-role button when enabled [Seiei Miyagi]
|
69
|
+
* Support for aria-role link when enabled
|
70
|
+
* Support for `validation_message` filter with :field and :fillable_field selectors
|
71
|
+
* Deprecation warnings show source location [Koichi ITO]
|
72
|
+
|
73
|
+
### Changed
|
74
|
+
|
75
|
+
* Ruby 2.5.0+ is now required
|
76
|
+
* Deprecated direct manipulation of the driver and server registries
|
77
|
+
|
78
|
+
### Fixed
|
79
|
+
|
80
|
+
* Ruby 2.7 warning in minitest `assert_text` [Eileen M. Uchitelle]
|
81
|
+
|
82
|
+
|
1
83
|
# Version 3.32.2
|
2
84
|
Release date: 2020-05-16
|
3
85
|
|
4
86
|
### Fixed
|
5
87
|
|
6
88
|
* Don't use lazy enumerator with JRuby due to leaking threads
|
7
|
-
* Ruby 2
|
89
|
+
* Ruby 2.7 deprecation warning when registering Webrick [Jon Zeppieri]
|
8
90
|
* `have_text` description [Juan Pablo Rinaldi]
|
9
91
|
|
10
92
|
# Version 3.32.1
|
@@ -21,7 +103,7 @@ Release date: 2020-03-29
|
|
21
103
|
### Added
|
22
104
|
|
23
105
|
* Support `delay` setting on click with Selenium
|
24
|
-
* Implement rapid set for values longer
|
106
|
+
* Implement rapid set for values longer than 30 characters in text fields with Selenium
|
25
107
|
|
26
108
|
### Fixed
|
27
109
|
|
@@ -142,8 +224,8 @@ Release date: 2019-06-27
|
|
142
224
|
|
143
225
|
### Fixed
|
144
226
|
|
145
|
-
*
|
146
|
-
both source and target are
|
227
|
+
* Work around issue with chromedriver 76/77 in W3C mode losing mouse state during legacy drag. Only fixed if
|
228
|
+
both source and target are simultaneously inside the viewport - Issue #2223
|
147
229
|
* Negative ancestor expectations/predicates were incorrectly checking siblings rather than ancestors
|
148
230
|
|
149
231
|
# Version 3.24.0
|
@@ -422,7 +504,7 @@ Release date: 2018-10-23
|
|
422
504
|
|
423
505
|
### Fixed
|
424
506
|
|
425
|
-
* Selector `css` expression
|
507
|
+
* Selector `css` expression definition declared filters now work again
|
426
508
|
* Cleaned up warnings [Yuji Yaginuma]
|
427
509
|
* Workaround installation of rspec matcher proxies under jruby by reverting to the old solution not using prepend, so jruby bugs are not hit - Issue #2115
|
428
510
|
|
@@ -539,7 +621,7 @@ Release date: 2018-07-19
|
|
539
621
|
|
540
622
|
### Fixed
|
541
623
|
|
542
|
-
* Make selenium driver :backspace clear
|
624
|
+
* Make selenium driver :backspace clear strategy work even if caret location is in middle of field content [Champier Cyril]
|
543
625
|
* Selenium issue with fieldset nested in disabled fieldset not being considered disabled
|
544
626
|
* `Session#evaluate_script` and `Element#evaluate_script` now strip leading/trailing whitespace from scripts [Ian Lesperance]
|
545
627
|
|
@@ -638,7 +720,7 @@ Release date: 2018-04-13
|
|
638
720
|
### Fixes
|
639
721
|
|
640
722
|
* Fix expression filter descriptions in some selector failure messages
|
641
|
-
* Fix compounding of negated
|
723
|
+
* Fix compounding of negated matchers - Issue #2010
|
642
724
|
|
643
725
|
# Version 3.0.1
|
644
726
|
Release date: 2018-04-06
|
@@ -912,7 +994,7 @@ Release date: 2016-12-05
|
|
912
994
|
* Options for clearing session/local storage on reset added to the Selenium driver
|
913
995
|
* Window size changes wait for the size to stabilize
|
914
996
|
* Defined return value for most actions
|
915
|
-
* Ignore specific error when
|
997
|
+
* Ignore specific error when quitting selenium driver instance - Issue #1773 [Dylan Reichstadt, Thomas Walpole]
|
916
998
|
* Warn on selenium unknown errors rather than raising when quitting driver [Adam Pohorecki, Thomas Walpole]
|
917
999
|
* Capybara::Result#each now returns an `Enumerator` when called without a block - Issue #1777 [Thomas Walpole]
|
918
1000
|
|
@@ -974,7 +1056,7 @@ Release date: 2016-09-19
|
|
974
1056
|
|
975
1057
|
### Fixed
|
976
1058
|
|
977
|
-
* Issue with rack-test driver and
|
1059
|
+
* Issue with rack-test driver and obsolete mime-types when using `#attach_file` - Issue #1756 [Thomas Walpole]
|
978
1060
|
|
979
1061
|
### Added
|
980
1062
|
|
@@ -1041,7 +1123,7 @@ Release date: 2016-04-07
|
|
1041
1123
|
|
1042
1124
|
### Added
|
1043
1125
|
|
1044
|
-
* Capybara now waits for requests to Capybaras server to complete while
|
1126
|
+
* Capybara now waits for requests to Capybaras server to complete while resetting the session [John Hawthorn, Thomas Walpole]
|
1045
1127
|
* Capybara.reuse_server option to allow disabling of sharing server instance between sessions [Thomas Walpole]
|
1046
1128
|
* :multiple filter added to relevant selectors [Thomas Walpole]
|
1047
1129
|
* Provided server registrations for :webrick and :puma. Capybara.server = :puma for testing with Rails 5 [Thomas Walpole]
|
@@ -1055,7 +1137,7 @@ Release date: 2016-04-07
|
|
1055
1137
|
|
1056
1138
|
# Version 2.6.2
|
1057
1139
|
|
1058
|
-
|
1140
|
+
Release date: 2016-01-27
|
1059
1141
|
|
1060
1142
|
### Fixed
|
1061
1143
|
|
@@ -1601,8 +1683,8 @@ Release date: 2011-06-14
|
|
1601
1683
|
* Rack::Test driver honours maxlength on input fields [Guilherme Carvalho]
|
1602
1684
|
* Rack::Test now works as expected with domains and subdomains [Jonas Nicklas]
|
1603
1685
|
* Session is reset more thoroughly between tests. [Jonas Nicklas]
|
1604
|
-
* Raise error when uploading non-
|
1605
|
-
* Rack
|
1686
|
+
* Raise error when uploading non-existent file [Jonas Nicklas]
|
1687
|
+
* Rack response body should respond to #each [Piotr Sarnacki]
|
1606
1688
|
* Deprecation warnings with selenium webdriver 0.2.0 [Aaron Gibraltar]
|
1607
1689
|
* Selenium Chrome no longer YELLS tagname [Carl Jackson & David W. Frank]
|
1608
1690
|
* Capybara no longer strips encoding before sending to Rack [Jonas Nicklas]
|
@@ -1744,7 +1826,7 @@ Release date: 2010-05-12
|
|
1744
1826
|
|
1745
1827
|
Release date: 2010-04-09
|
1746
1828
|
|
1747
|
-
This is a drop in compatible
|
1829
|
+
This is a drop in compatible maintenance release. It's mostly
|
1748
1830
|
important for driver authors.
|
1749
1831
|
|
1750
1832
|
### Added
|
@@ -1763,7 +1845,7 @@ important for driver authors.
|
|
1763
1845
|
|
1764
1846
|
Release date: 2010-03-22
|
1765
1847
|
|
1766
|
-
This is a
|
1848
|
+
This is a maintenance release with minor bug fixes, should be
|
1767
1849
|
drop in compatible.
|
1768
1850
|
|
1769
1851
|
### Added
|
data/README.md
CHANGED
@@ -7,8 +7,6 @@
|
|
7
7
|
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
8
8
|
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=capybara&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=capybara&package-manager=bundler&version-scheme=semver)
|
9
9
|
|
10
|
-
**Note** You are viewing the README for the 3.32.x version of Capybara.
|
11
|
-
|
12
10
|
Capybara helps you test web applications by simulating how a real user would
|
13
11
|
interact with your app. It is agnostic about the driver running your tests and
|
14
12
|
comes with Rack::Test and Selenium support built in. WebKit is supported
|
@@ -76,7 +74,7 @@ GitHub): http://groups.google.com/group/ruby-capybara
|
|
76
74
|
|
77
75
|
## <a name="setup"></a>Setup
|
78
76
|
|
79
|
-
Capybara requires Ruby 2.
|
77
|
+
Capybara requires Ruby 2.5.0 or later. To install, add this line to your
|
80
78
|
`Gemfile` and run `bundle install`:
|
81
79
|
|
82
80
|
```ruby
|
@@ -149,7 +147,7 @@ require 'capybara/rspec'
|
|
149
147
|
|
150
148
|
If you are using Rails, put your Capybara specs in `spec/features` or `spec/system` (only works
|
151
149
|
if [you have it configured in
|
152
|
-
RSpec](https://
|
150
|
+
RSpec](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/directory-structure))
|
153
151
|
and if you have your Capybara specs in a different directory, then tag the
|
154
152
|
example groups with `type: :feature` or `type: :system` depending on which type of test you're writing.
|
155
153
|
|
@@ -1055,6 +1053,13 @@ additional info about how the underlying driver can be configured.
|
|
1055
1053
|
are testing for specific server errors and using multiple sessions make sure to test for the
|
1056
1054
|
errors using the initial session (usually :default)
|
1057
1055
|
|
1056
|
+
* If WebMock is enabled, you may encounter a "Too many open files"
|
1057
|
+
error. A simple `page.find` call may cause thousands of HTTP requests
|
1058
|
+
until the timeout occurs. By default, WebMock will cause each of these
|
1059
|
+
requests to spawn a new connection. To work around this problem, you
|
1060
|
+
may need to [enable WebMock's `net_http_connect_on_start: true`
|
1061
|
+
parameter](https://github.com/bblimke/webmock/blob/master/README.md#connecting-on-nethttpstart).
|
1062
|
+
|
1058
1063
|
## <a name="threadsafe"></a>"Threadsafe" mode
|
1059
1064
|
|
1060
1065
|
In normal mode most of Capybara's configuration options are global settings which can cause issues
|
data/lib/capybara.rb
CHANGED
@@ -5,6 +5,7 @@ require 'nokogiri'
|
|
5
5
|
require 'xpath'
|
6
6
|
require 'forwardable'
|
7
7
|
require 'capybara/config'
|
8
|
+
require 'capybara/registration_container'
|
8
9
|
|
9
10
|
module Capybara
|
10
11
|
class CapybaraError < StandardError; end
|
@@ -81,6 +82,7 @@ module Capybara
|
|
81
82
|
# - **default_selector** (`:css`, `:xpath` = `:css`) - Methods which take a selector use the given type by default. See also {Capybara::Selector}.
|
82
83
|
# - **default_set_options** (Hash = `{}`) - The default options passed to {Capybara::Node::Element#set Element#set}.
|
83
84
|
# - **enable_aria_label** (Boolean = `false`) - Whether fields, links, and buttons will match against `aria-label` attribute.
|
85
|
+
# - **enable_aria_role** (Boolean = `false`) - Selectors will check for relevant aria role (currently only `button`).
|
84
86
|
# - **exact** (Boolean = `false`) - Whether locators are matched exactly or with substrings. Only affects selector conditions
|
85
87
|
# written using the `XPath#is` method.
|
86
88
|
# - **exact_text** (Boolean = `false`) - Whether the text matchers and `:text` filter match exactly or on substrings.
|
@@ -93,6 +95,7 @@ module Capybara
|
|
93
95
|
# - **save_path** (String = `Dir.pwd`) - Where to put pages saved through {Capybara::Session#save_page save_page}, {Capybara::Session#save_screenshot save_screenshot},
|
94
96
|
# {Capybara::Session#save_and_open_page save_and_open_page}, or {Capybara::Session#save_and_open_screenshot save_and_open_screenshot}.
|
95
97
|
# - **server** (Symbol = `:default` (which uses puma)) - The name of the registered server to use when running the app under test.
|
98
|
+
# - **server_port** (Integer) - The port Capybara will run the application server on, if not specified a random port will be used.
|
96
99
|
# - **server_errors** (Array\<Class> = `[Exception]`) - Error classes that should be raised in the tests if they are raised in the server
|
97
100
|
# and {configure raise_server_errors} is `true`.
|
98
101
|
# - **test_id** (Symbol, String, `nil` = `nil`) - Optional attribute to match locator against with built-in selectors along with id.
|
@@ -124,7 +127,7 @@ module Capybara
|
|
124
127
|
# @yieldreturn [Capybara::Driver::Base] A Capybara driver instance
|
125
128
|
#
|
126
129
|
def register_driver(name, &block)
|
127
|
-
drivers
|
130
|
+
drivers.send(:register, name, block)
|
128
131
|
end
|
129
132
|
|
130
133
|
##
|
@@ -143,7 +146,7 @@ module Capybara
|
|
143
146
|
# @yieldparam host The host/ip to bind to
|
144
147
|
#
|
145
148
|
def register_server(name, &block)
|
146
|
-
servers
|
149
|
+
servers.send(:register, name.to_sym, block)
|
147
150
|
end
|
148
151
|
|
149
152
|
##
|
@@ -197,11 +200,11 @@ module Capybara
|
|
197
200
|
end
|
198
201
|
|
199
202
|
def drivers
|
200
|
-
@drivers ||=
|
203
|
+
@drivers ||= RegistrationContainer.new
|
201
204
|
end
|
202
205
|
|
203
206
|
def servers
|
204
|
-
@servers ||=
|
207
|
+
@servers ||= RegistrationContainer.new
|
205
208
|
end
|
206
209
|
|
207
210
|
# Wraps the given string, which should contain an HTML document or fragment
|
@@ -349,7 +352,8 @@ module Capybara
|
|
349
352
|
#
|
350
353
|
# Yield a block using a specific session name or {Capybara::Session} instance.
|
351
354
|
#
|
352
|
-
def using_session(name_or_session)
|
355
|
+
def using_session(name_or_session, &block)
|
356
|
+
previous_session = current_session
|
353
357
|
previous_session_info = {
|
354
358
|
specified_session: specified_session,
|
355
359
|
session_name: session_name,
|
@@ -362,7 +366,12 @@ module Capybara
|
|
362
366
|
else
|
363
367
|
self.session_name = name_or_session
|
364
368
|
end
|
365
|
-
|
369
|
+
|
370
|
+
if block.arity.zero?
|
371
|
+
yield
|
372
|
+
else
|
373
|
+
yield current_session, previous_session
|
374
|
+
end
|
366
375
|
ensure
|
367
376
|
self.session_name, self.specified_session = previous_session_info.values_at(:session_name, :specified_session)
|
368
377
|
self.current_driver, self.app = previous_session_info.values_at(:current_driver, :app) if threadsafe
|
@@ -394,7 +403,7 @@ module Capybara
|
|
394
403
|
template.inner_html = ''
|
395
404
|
end
|
396
405
|
document.xpath('//textarea').each do |textarea|
|
397
|
-
textarea['_capybara_raw_value'] = textarea.content.
|
406
|
+
textarea['_capybara_raw_value'] = textarea.content.delete_prefix("\n")
|
398
407
|
end
|
399
408
|
end
|
400
409
|
end
|
@@ -475,7 +484,7 @@ module Capybara
|
|
475
484
|
require 'capybara/rack_test/node'
|
476
485
|
require 'capybara/rack_test/form'
|
477
486
|
require 'capybara/rack_test/browser'
|
478
|
-
require 'capybara/rack_test/css_handlers
|
487
|
+
require 'capybara/rack_test/css_handlers'
|
479
488
|
|
480
489
|
require 'capybara/selenium/node'
|
481
490
|
require 'capybara/selenium/driver'
|
@@ -501,6 +510,7 @@ Capybara.configure do |config|
|
|
501
510
|
config.visible_text_only = false
|
502
511
|
config.automatic_label_click = false
|
503
512
|
config.enable_aria_label = false
|
513
|
+
config.enable_aria_role = false
|
504
514
|
config.reuse_server = true
|
505
515
|
config.default_set_options = {}
|
506
516
|
config.test_id = nil
|
data/lib/capybara/config.rb
CHANGED
@@ -9,11 +9,9 @@ module Capybara
|
|
9
9
|
|
10
10
|
OPTIONS = %i[app reuse_server threadsafe server default_driver javascript_driver allow_gumbo].freeze
|
11
11
|
|
12
|
-
attr_accessor :app
|
13
|
-
attr_reader :reuse_server, :threadsafe
|
14
|
-
attr_reader :session_options
|
12
|
+
attr_accessor :app, :allow_gumbo
|
13
|
+
attr_reader :reuse_server, :threadsafe, :session_options
|
15
14
|
attr_writer :default_driver, :javascript_driver
|
16
|
-
attr_accessor :allow_gumbo
|
17
15
|
|
18
16
|
SessionConfig::OPTIONS.each do |method|
|
19
17
|
def_delegators :session_options, method, "#{method}="
|
@@ -83,10 +81,10 @@ module Capybara
|
|
83
81
|
@javascript_driver || :selenium
|
84
82
|
end
|
85
83
|
|
86
|
-
def deprecate(method, alternate_method, once
|
84
|
+
def deprecate(method, alternate_method, once: false)
|
87
85
|
@deprecation_notified ||= {}
|
88
86
|
unless once && @deprecation_notified[method]
|
89
|
-
warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead"
|
87
|
+
Capybara::Helpers.warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead: #{Capybara::Helpers.filter_backtrace(caller)}"
|
90
88
|
end
|
91
89
|
@deprecation_notified[method] = true
|
92
90
|
end
|
data/lib/capybara/cucumber.rb
CHANGED
@@ -22,6 +22,6 @@ end
|
|
22
22
|
Before do |scenario|
|
23
23
|
scenario.source_tag_names.each do |tag|
|
24
24
|
driver_name = tag.sub(/^@/, '').to_sym
|
25
|
-
Capybara.current_driver = driver_name if Capybara.drivers
|
25
|
+
Capybara.current_driver = driver_name if Capybara.drivers[driver_name]
|
26
26
|
end
|
27
27
|
end
|
data/lib/capybara/driver/base.rb
CHANGED
@@ -59,6 +59,10 @@ class Capybara::Driver::Base
|
|
59
59
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#status_code'
|
60
60
|
end
|
61
61
|
|
62
|
+
def send_keys(*)
|
63
|
+
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#send_keys'
|
64
|
+
end
|
65
|
+
|
62
66
|
##
|
63
67
|
#
|
64
68
|
# @param frame [Capybara::Node::Element, :parent, :top] The iframe element to switch to
|
data/lib/capybara/helpers.rb
CHANGED
@@ -15,7 +15,7 @@ module Capybara
|
|
15
15
|
# @return [String] Normalized text
|
16
16
|
#
|
17
17
|
def normalize_whitespace(text)
|
18
|
-
warn 'DEPRECATED: Capybara::Helpers::normalize_whitespace is deprecated, please update your driver'
|
18
|
+
Capybara::Helpers.warn 'DEPRECATED: Capybara::Helpers::normalize_whitespace is deprecated, please update your driver'
|
19
19
|
text.to_s.gsub(/[[:space:]]+/, ' ').strip
|
20
20
|
end
|
21
21
|
|
@@ -70,6 +70,30 @@ module Capybara
|
|
70
70
|
count == 1 ? singular : plural
|
71
71
|
end
|
72
72
|
|
73
|
+
def filter_backtrace(trace)
|
74
|
+
return 'No backtrace' unless trace
|
75
|
+
|
76
|
+
filter = %r{lib/capybara/|lib/rspec/|lib/minitest/}
|
77
|
+
new_trace = trace.take_while { |line| line !~ filter }
|
78
|
+
new_trace = trace.reject { |line| line =~ filter } if new_trace.empty?
|
79
|
+
new_trace = trace.dup if new_trace.empty?
|
80
|
+
|
81
|
+
new_trace.first.split(/:in /, 2).first
|
82
|
+
end
|
83
|
+
|
84
|
+
def warn(message, uplevel: 1)
|
85
|
+
return Kernel.warn(message, uplevel: uplevel) if RUBY_VERSION >= '2.6'
|
86
|
+
|
87
|
+
# TODO: Remove when we drop support for Ruby 2.5
|
88
|
+
# Workaround for emulating `warn '...', uplevel: n` in Ruby 2.5 or lower.
|
89
|
+
if (match = /^(?<file>.+?):(?<line>\d+)(?::in `.*')?/.match(caller[uplevel]))
|
90
|
+
location = [match[:file], match[:line]].join(':')
|
91
|
+
Kernel.warn "#{location}: #{message}"
|
92
|
+
else
|
93
|
+
Kernel.warn message
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
73
97
|
if defined?(Process::CLOCK_MONOTONIC)
|
74
98
|
def monotonic_time; Process.clock_gettime Process::CLOCK_MONOTONIC; end
|
75
99
|
else
|
data/lib/capybara/minitest.rb
CHANGED
@@ -50,15 +50,14 @@ module Capybara
|
|
50
50
|
|
51
51
|
%w[text no_text title no_title current_path no_current_path].each do |assertion_name|
|
52
52
|
class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
|
53
|
-
def assert_#{assertion_name}
|
53
|
+
def assert_#{assertion_name}(*args, **kwargs, &optional_filter_block)
|
54
54
|
self.assertions +=1
|
55
55
|
subject, args = determine_subject(args)
|
56
|
-
subject.assert_#{assertion_name}(*args)
|
56
|
+
subject.assert_#{assertion_name}(*args, **kwargs, &optional_filter_block)
|
57
57
|
rescue Capybara::ExpectationNotMet => e
|
58
58
|
raise ::Minitest::Assertion, e.message
|
59
59
|
end
|
60
60
|
ASSERTION
|
61
|
-
ruby2_keywords "assert_#{assertion_name}" if respond_to?(:ruby2_keywords)
|
62
61
|
end
|
63
62
|
|
64
63
|
alias_method :refute_title, :assert_no_title
|