capybara 2.15.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/History.md +137 -2
- data/README.md +36 -25
- data/lib/capybara/config.rb +11 -57
- data/lib/capybara/cucumber.rb +2 -3
- data/lib/capybara/driver/base.rb +19 -16
- data/lib/capybara/driver/node.rb +5 -4
- data/lib/capybara/dsl.rb +1 -0
- data/lib/capybara/helpers.rb +19 -29
- data/lib/capybara/minitest/spec.rb +16 -13
- data/lib/capybara/minitest.rb +140 -137
- data/lib/capybara/node/actions.rb +68 -89
- data/lib/capybara/node/base.rb +11 -18
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +8 -8
- data/lib/capybara/node/element.rb +32 -42
- data/lib/capybara/node/finders.rb +64 -71
- data/lib/capybara/node/matchers.rb +50 -71
- data/lib/capybara/node/simple.rb +11 -17
- data/lib/capybara/queries/ancestor_query.rb +12 -8
- data/lib/capybara/queries/base_query.rb +22 -18
- data/lib/capybara/queries/current_path_query.rb +12 -25
- data/lib/capybara/queries/match_query.rb +3 -7
- data/lib/capybara/queries/selector_query.rb +100 -96
- data/lib/capybara/queries/sibling_query.rb +5 -5
- data/lib/capybara/queries/text_query.rb +35 -35
- data/lib/capybara/queries/title_query.rb +8 -11
- data/lib/capybara/rack_test/browser.rb +15 -18
- data/lib/capybara/rack_test/css_handlers.rb +6 -4
- data/lib/capybara/rack_test/driver.rb +6 -10
- data/lib/capybara/rack_test/form.rb +52 -39
- data/lib/capybara/rack_test/node.rb +93 -63
- data/lib/capybara/rails.rb +2 -6
- data/lib/capybara/result.rb +22 -22
- data/lib/capybara/rspec/compound.rb +5 -10
- data/lib/capybara/rspec/features.rb +17 -48
- data/lib/capybara/rspec/matcher_proxies.rb +31 -15
- data/lib/capybara/rspec/matchers.rb +116 -58
- data/lib/capybara/rspec.rb +5 -10
- data/lib/capybara/selector/css.rb +6 -11
- data/lib/capybara/selector/filter.rb +1 -17
- data/lib/capybara/selector/filter_set.rb +18 -15
- data/lib/capybara/selector/filters/base.rb +7 -6
- data/lib/capybara/selector/filters/expression_filter.rb +6 -23
- data/lib/capybara/selector/filters/node_filter.rb +2 -12
- data/lib/capybara/selector/selector.rb +28 -34
- data/lib/capybara/selector.rb +129 -117
- data/lib/capybara/selenium/driver.rb +172 -163
- data/lib/capybara/selenium/node.rb +218 -104
- data/lib/capybara/server.rb +3 -2
- data/lib/capybara/session/config.rb +47 -59
- data/lib/capybara/session/matchers.rb +23 -14
- data/lib/capybara/session.rb +175 -229
- data/lib/capybara/spec/fixtures/no_extension +1 -0
- data/lib/capybara/spec/public/test.js +38 -6
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -0
- data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -2
- data/lib/capybara/spec/session/accept_prompt_spec.rb +30 -1
- data/lib/capybara/spec/session/all_spec.rb +31 -18
- data/lib/capybara/spec/session/ancestor_spec.rb +6 -8
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +6 -5
- data/lib/capybara/spec/session/assert_current_path.rb +12 -11
- data/lib/capybara/spec/session/assert_selector.rb +1 -0
- data/lib/capybara/spec/session/assert_text.rb +31 -23
- data/lib/capybara/spec/session/assert_title.rb +13 -3
- data/lib/capybara/spec/session/attach_file_spec.rb +57 -29
- data/lib/capybara/spec/session/body_spec.rb +1 -0
- data/lib/capybara/spec/session/check_spec.rb +7 -6
- data/lib/capybara/spec/session/choose_spec.rb +5 -4
- data/lib/capybara/spec/session/click_button_spec.rb +24 -32
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -7
- data/lib/capybara/spec/session/click_link_spec.rb +8 -7
- data/lib/capybara/spec/session/current_scope_spec.rb +4 -3
- data/lib/capybara/spec/session/current_url_spec.rb +19 -8
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -0
- data/lib/capybara/spec/session/element/assert_match_selector.rb +1 -1
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +1 -1
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +5 -5
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +23 -0
- data/lib/capybara/spec/session/evaluate_script_spec.rb +5 -4
- data/lib/capybara/spec/session/execute_script_spec.rb +4 -3
- data/lib/capybara/spec/session/fill_in_spec.rb +30 -5
- data/lib/capybara/spec/session/find_button_spec.rb +4 -3
- data/lib/capybara/spec/session/find_by_id_spec.rb +2 -1
- data/lib/capybara/spec/session/find_field_spec.rb +9 -15
- data/lib/capybara/spec/session/find_link_spec.rb +6 -5
- data/lib/capybara/spec/session/find_spec.rb +37 -31
- data/lib/capybara/spec/session/first_spec.rb +60 -33
- data/lib/capybara/spec/session/frame/frame_title_spec.rb +23 -0
- data/lib/capybara/spec/session/frame/frame_url_spec.rb +23 -0
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +2 -1
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +9 -16
- data/lib/capybara/spec/session/go_back_spec.rb +1 -0
- data/lib/capybara/spec/session/go_forward_spec.rb +1 -0
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +69 -0
- data/lib/capybara/spec/session/has_button_spec.rb +2 -1
- data/lib/capybara/spec/session/has_css_spec.rb +3 -2
- data/lib/capybara/spec/session/has_current_path_spec.rb +49 -22
- data/lib/capybara/spec/session/has_field_spec.rb +4 -3
- data/lib/capybara/spec/session/has_link_spec.rb +5 -4
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +76 -0
- data/lib/capybara/spec/session/has_select_spec.rb +32 -31
- data/lib/capybara/spec/session/has_selector_spec.rb +5 -4
- data/lib/capybara/spec/session/has_table_spec.rb +2 -1
- data/lib/capybara/spec/session/has_text_spec.rb +9 -13
- data/lib/capybara/spec/session/has_title_spec.rb +1 -0
- data/lib/capybara/spec/session/has_xpath_spec.rb +1 -0
- data/lib/capybara/spec/session/headers.rb +2 -1
- data/lib/capybara/spec/session/html_spec.rb +1 -0
- data/lib/capybara/spec/session/node_spec.rb +107 -58
- data/lib/capybara/spec/session/node_wrapper_spec.rb +36 -0
- data/lib/capybara/spec/session/refresh_spec.rb +6 -2
- data/lib/capybara/spec/session/reset_session_spec.rb +19 -0
- data/lib/capybara/spec/session/response_code.rb +1 -0
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +1 -0
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +6 -11
- data/lib/capybara/spec/session/save_page_spec.rb +1 -17
- data/lib/capybara/spec/session/save_screenshot_spec.rb +3 -3
- data/lib/capybara/spec/session/select_spec.rb +21 -20
- data/lib/capybara/spec/session/selectors_spec.rb +2 -2
- data/lib/capybara/spec/session/sibling_spec.rb +1 -1
- data/lib/capybara/spec/session/text_spec.rb +17 -3
- data/lib/capybara/spec/session/title_spec.rb +11 -1
- data/lib/capybara/spec/session/uncheck_spec.rb +4 -3
- data/lib/capybara/spec/session/unselect_spec.rb +7 -6
- data/lib/capybara/spec/session/visit_spec.rb +64 -3
- data/lib/capybara/spec/session/window/become_closed_spec.rb +2 -1
- data/lib/capybara/spec/session/window/current_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/open_new_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +2 -1
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -1
- data/lib/capybara/spec/session/window/window_spec.rb +12 -12
- data/lib/capybara/spec/session/window/windows_spec.rb +2 -3
- data/lib/capybara/spec/session/window/within_window_spec.rb +15 -71
- data/lib/capybara/spec/session/within_spec.rb +1 -0
- data/lib/capybara/spec/spec_helper.rb +36 -18
- data/lib/capybara/spec/test_app.rb +17 -9
- data/lib/capybara/spec/views/form.erb +7 -0
- data/lib/capybara/spec/views/initial_alert.erb +10 -0
- data/lib/capybara/spec/views/with_fixed_header_footer.erb +17 -0
- data/lib/capybara/spec/views/with_hover.erb +5 -0
- data/lib/capybara/spec/views/with_html.erb +27 -1
- data/lib/capybara/spec/views/with_js.erb +11 -0
- data/lib/capybara/spec/views/within_frames.erb +4 -1
- data/lib/capybara/version.rb +2 -1
- data/lib/capybara/window.rb +6 -10
- data/lib/capybara.rb +29 -26
- data/spec/basic_node_spec.rb +1 -0
- data/spec/capybara_spec.rb +16 -69
- data/spec/dsl_spec.rb +5 -13
- data/spec/filter_set_spec.rb +5 -4
- data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +3 -2
- data/spec/minitest_spec.rb +13 -4
- data/spec/minitest_spec_spec.rb +12 -3
- data/spec/per_session_config_spec.rb +9 -8
- data/spec/rack_test_spec.rb +21 -20
- data/spec/result_spec.rb +17 -16
- data/spec/rspec/features_spec.rb +17 -14
- data/spec/rspec/scenarios_spec.rb +5 -7
- data/spec/rspec/shared_spec_matchers.rb +96 -99
- data/spec/rspec/views_spec.rb +2 -1
- data/spec/rspec_matchers_spec.rb +18 -2
- data/spec/rspec_spec.rb +11 -15
- data/spec/selector_spec.rb +5 -6
- data/spec/selenium_spec_chrome.rb +20 -11
- data/spec/selenium_spec_edge.rb +27 -0
- data/spec/selenium_spec_ie.rb +31 -0
- data/spec/selenium_spec_marionette.rb +38 -12
- data/spec/server_spec.rb +33 -33
- data/spec/session_spec.rb +2 -1
- data/spec/shared_selenium_session.rb +82 -22
- data/spec/spec_helper.rb +3 -6
- metadata +76 -81
- data/lib/capybara/query.rb +0 -7
- data/spec/selenium_spec_firefox.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8389b150e2b44270ed1d94b8f6e0f48af613f1a2f28b8ad772e35cb7db635ad7
|
4
|
+
data.tar.gz: bace2657813bc0681e4586ba2c96a66e824e12651f0e839a8649ed491f0eafa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ffed0a0be90e5d8bf022b48d261aa160646562095114ca383a446431ab57403d67a6ccf252129a477484a6ea1bdc1edfefa6930571961e6307b5ce180c6aa30
|
7
|
+
data.tar.gz: e5956efba3a7e4a6833a9b63e61c6f136a3210eb77ac44d8b1603b81b6e5bea7bde1ea3fd4c76b8eda6a10f61c1e0e805aef7f8aa4bcf801061c46a7fded1c02
|
data/History.md
CHANGED
@@ -1,6 +1,138 @@
|
|
1
|
+
# Version 3.0.0
|
2
|
+
Release date: 2018-04-05
|
3
|
+
|
4
|
+
### Changed
|
5
|
+
|
6
|
+
* Selenium driver only closes extra windows for browsers where that is known to work (Firefox, Chrome)
|
7
|
+
* "threadsafe" mode is no longer considered beta
|
8
|
+
|
9
|
+
### Fixes
|
10
|
+
|
11
|
+
* Multiple file attach_file with Firefox
|
12
|
+
* Use Puma::Server directly rather than Rack::Handler::Puma so signal handlers don't prevent test quitting
|
13
|
+
|
14
|
+
# Version 3.0.0.rc2
|
15
|
+
Release date: 2018-03-23
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
* Drivers are now expected to return visible text more in line with the WebDriver spec for visible text
|
20
|
+
* Drivers are expected to close extra windows when resetting the session
|
21
|
+
* Selenium driver supports Date/Time when filling in date/time/datetime-local inputs
|
22
|
+
* `current_url` returns the url for the top level browsing context
|
23
|
+
* `title` returns the title for the top level browsing context
|
24
|
+
|
25
|
+
### Added
|
26
|
+
|
27
|
+
* `Driver#frame_url` returns the url for the current frame
|
28
|
+
* `Driver#frame_title` returns the title for the current frame
|
29
|
+
|
30
|
+
# Version 3.0.0.rc1
|
31
|
+
Release date: 2018-03-02
|
32
|
+
|
33
|
+
### Added
|
34
|
+
* Support for libraries wrapping Capybara elements and providing a `#to_capybara_node` method
|
35
|
+
|
36
|
+
### Changed
|
37
|
+
|
38
|
+
* `first` now raises ElementNotFound, by default, instead of returning nil when no matches are found - Issue #1507
|
39
|
+
* 'all' now waits for at least one matching element by default. Pass `wait: false` if you want the previous
|
40
|
+
behavior where an empty result would be returned immediately if no matching elements exist yet.
|
41
|
+
* ArgumentError raised if extra parameters passed to selector queries
|
42
|
+
|
43
|
+
### Removed
|
44
|
+
|
45
|
+
* Ruby < 2.2.2 support
|
46
|
+
* `Capybara.exact_options` no longer exists. Just use `exact: true` on relevant actions/finders if necessary.
|
47
|
+
* All previously deprecated methods removed
|
48
|
+
* RSpec 2.x support
|
49
|
+
* selenium-webdriver 2.x support
|
50
|
+
* Nokogiri < 1.8 support
|
51
|
+
* `field_labeled` alias for `find_field`
|
52
|
+
|
53
|
+
# Version 2.18.0
|
54
|
+
Release date: 2018-02-12
|
55
|
+
|
56
|
+
### Fixed
|
57
|
+
|
58
|
+
* Firefox/geckodriver setting of contenteditable childs contents
|
59
|
+
* Ignore Selenium::WebDriver::Error::SessionNotCreatedError when quitting driver [Tim Connor]
|
60
|
+
|
61
|
+
### Removed
|
62
|
+
|
63
|
+
* Headless chrome modal JS injection that is no longer needed for Chrome 64+/chromedriver 2.35+
|
64
|
+
|
65
|
+
|
66
|
+
# Version 2.17.0
|
67
|
+
Release date: 2018-01-02
|
68
|
+
|
69
|
+
### Added
|
70
|
+
|
71
|
+
* `have_all_of_selectors`, `have_none_of_selectors` RSpec matchers for parity with minitest assertions [Thomas Walpole]
|
72
|
+
|
73
|
+
### Fixed
|
74
|
+
|
75
|
+
* Allow xpath 3.x gem [Thomas Walpole]
|
76
|
+
* Issue when drivers returned nil for `current_path` and a matcher was used with a Regexp [Thomas Walpole]
|
77
|
+
* Error message when visible element not found, but non-visible was [Andy Klimczak]
|
78
|
+
|
79
|
+
# Version 2.16.1
|
80
|
+
Release date: 2017-11-20
|
81
|
+
|
82
|
+
### Fixed
|
83
|
+
|
84
|
+
* Fix rack_test driver for rack_test 0.7.1/0.8.0 [Thomas Walpole]
|
85
|
+
* `accept_prompt` response text can contain quotes when using selenium with headless chrome [Thomas Walpole]
|
86
|
+
|
87
|
+
# Version 2.16.0
|
88
|
+
Release date: 2017-11-13
|
89
|
+
|
90
|
+
### Added
|
91
|
+
|
92
|
+
* Attempt to move element into view when selenium doesn't correctly do it - See PR #1917 [Thomas Walpole]
|
93
|
+
* `current_path` matchers will now autodetect path vs url based on string to be matched. Deprecates
|
94
|
+
`:only_path` in favor of `:ignore_query` option [Thomas Walpole]
|
95
|
+
* Session#evaluate_async_script [Thomas Walpole]
|
96
|
+
|
97
|
+
### Fixed
|
98
|
+
|
99
|
+
* Default prompt value when using headless Chrome works correctly [Thomas Walpole]
|
100
|
+
* Support new modal error returned by selenium-webdriver 3.7 for W3C drivers [Thomas Walpole]
|
101
|
+
* Calling `respond_to?` on the object passed to `Capybara.configure` block - Issue #1935
|
102
|
+
|
103
|
+
# Version 2.15.4
|
104
|
+
Release date: 2017-10-07
|
105
|
+
|
106
|
+
### Fixed
|
107
|
+
* Visiting an absolute URL shouldn't overwrite the port when no server or always_include_port=false - Issue #1921
|
108
|
+
|
109
|
+
# Version 2.15.3
|
110
|
+
Release date: 2017-10-03
|
111
|
+
|
112
|
+
### Fixed
|
113
|
+
* Visiting '/' when Capybara.app_host has a trailing '/' - Issue #1918 [Thomas Walpole]
|
114
|
+
|
115
|
+
# Version 2.15.2
|
116
|
+
Release date: 2017-10-02
|
117
|
+
|
118
|
+
### Fixed
|
119
|
+
|
120
|
+
* Include within scope description in element not found/ambiguous errors [Thomas Walpole]
|
121
|
+
* Raise error when no activation block is passed to modal methods if using headless chrome [Thomas Walpole]
|
122
|
+
* Don't retry element access when inspecting [Ivan Neverov]
|
123
|
+
* Don't override a specified port (even if it is default port) in visited url [Thomas Walpole]
|
124
|
+
|
125
|
+
# Version 2.15.1
|
126
|
+
|
127
|
+
Release date: 2017-08-04
|
128
|
+
|
129
|
+
### Fixed
|
130
|
+
|
131
|
+
* `attach_file` with no extension/MIME type when using the `:rack_test` driver [Thomas Walpole]
|
132
|
+
|
1
133
|
# Version 2.15.0
|
2
134
|
|
3
|
-
Release
|
135
|
+
Release date: 2017-08-04
|
4
136
|
|
5
137
|
### Added
|
6
138
|
|
@@ -12,9 +144,11 @@ Release data: unreleased
|
|
12
144
|
than waiting for one to pass/fail before checking the second. Will make `#or` more performant and confirm
|
13
145
|
both conditions are true "simultaneously" for `and`. [Thomas Walpole]
|
14
146
|
If you still want the
|
147
|
+
* Default filter values are now included in error descriptions [Thomas Walpole]
|
15
148
|
* Add `Session#refresh` [Thomas Walpole]
|
16
149
|
* Loosened restrictions on where `Session#within_window` can be called from [Thomas Walpole]
|
17
150
|
* Switched from `mime-types` dependency to `mini_mime` [Jason Frey]
|
151
|
+
|
18
152
|
# Version 2.14.4
|
19
153
|
|
20
154
|
Release date: 2017-06-27
|
@@ -172,6 +306,7 @@ Release date: 2016-10-05
|
|
172
306
|
Release date: 2016-09-29
|
173
307
|
|
174
308
|
### Fixed
|
309
|
+
|
175
310
|
* :label built-in selector finds nested label/control by control id if the label has no 'for' attribute [Thomas Walpole]
|
176
311
|
* Warning issued if an unknown selector type is specified [Thomas Walpole]
|
177
312
|
|
@@ -203,7 +338,7 @@ Release date: 2016-09-19
|
|
203
338
|
|
204
339
|
Release date: 2016-08-25
|
205
340
|
|
206
|
-
###Fixed
|
341
|
+
### Fixed
|
207
342
|
|
208
343
|
* Fixed error message from have_text when text is not found but contains regex special characters [Ryunosuke Sato]
|
209
344
|
* Warn when :exact option is passed that has no effect [Thomas Walpole]
|
data/README.md
CHANGED
@@ -1,15 +1,26 @@
|
|
1
1
|
# Capybara
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/teamcapybara/capybara.svg)](https://travis-ci.org/teamcapybara/capybara)
|
4
|
+
[![Build Status](https://ci.appveyor.com/api/projects/status/github/teamcapybara/capybara?svg=true)](https://ci.appveyor.com/api/projects/github/teamcapybara/capybara)
|
4
5
|
[![Dependency Status](https://gemnasium.com/teamcapybara/capybara.svg)](https://gemnasium.com/teamcapybara/capybara)
|
5
6
|
[![Code Climate](https://codeclimate.com/github/teamcapybara/capybara.svg)](https://codeclimate.com/github/teamcapybara/capybara)
|
6
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)
|
7
8
|
|
9
|
+
**Note** You are viewing the README for the development version of Capybara. If you are using the current release version
|
10
|
+
you can find the README at https://github.com/teamcapybara/capybara/blob/3.0_stable/README.md
|
11
|
+
|
12
|
+
|
8
13
|
Capybara helps you test web applications by simulating how a real user would
|
9
14
|
interact with your app. It is agnostic about the driver running your tests and
|
10
15
|
comes with Rack::Test and Selenium support built in. WebKit is supported
|
11
16
|
through an external gem.
|
12
17
|
|
18
|
+
## Support Capybara
|
19
|
+
|
20
|
+
If you and/or your company find value in Capybara and would like to contribute financially to its ongoing maintenance and development, please visit
|
21
|
+
<a href="https://www.patreon.com/capybara">Patreon</a>
|
22
|
+
|
23
|
+
|
13
24
|
**Need help?** Ask on the mailing list (please do not open an issue on
|
14
25
|
GitHub): http://groups.google.com/group/ruby-capybara
|
15
26
|
|
@@ -65,24 +76,19 @@ GitHub): http://groups.google.com/group/ruby-capybara
|
|
65
76
|
|
66
77
|
## <a name="setup"></a>Setup
|
67
78
|
|
68
|
-
Capybara requires Ruby
|
79
|
+
Capybara requires Ruby 2.2.2 or later. To install, add this line to your
|
69
80
|
`Gemfile` and run `bundle install`:
|
70
81
|
|
71
82
|
```ruby
|
72
83
|
gem 'capybara'
|
73
84
|
```
|
74
85
|
|
75
|
-
**Note:** If using Ruby < 2.0 you will also need to limit the version of rack to < 2.0
|
76
|
-
|
77
86
|
If the application that you are testing is a Rails app, add this line to your test helper file:
|
78
87
|
|
79
88
|
```ruby
|
80
89
|
require 'capybara/rails'
|
81
90
|
```
|
82
91
|
|
83
|
-
**Note:** In Rails 4.0/4.1 the default test environment (`config/environments/test.rb`) is [not threadsafe](https://github.com/rails/rails/issues/15089).
|
84
|
-
If you experience random errors about missing constants, add `config.allow_concurrency = false` to `config/environments/test.rb`.
|
85
|
-
|
86
92
|
If the application that you are testing is a Rack app, but not Rails, set Capybara.app to your Rack app:
|
87
93
|
|
88
94
|
```ruby
|
@@ -134,26 +140,26 @@ There are also explicit tags for each registered driver set up for you (`@seleni
|
|
134
140
|
|
135
141
|
## <a name="using-capybara-with-rspec"></a>Using Capybara with RSpec
|
136
142
|
|
137
|
-
Load RSpec
|
143
|
+
Load RSpec 3.x support by adding the following line (typically to your
|
138
144
|
`spec_helper.rb` file):
|
139
145
|
|
140
146
|
```ruby
|
141
147
|
require 'capybara/rspec'
|
142
148
|
```
|
143
149
|
|
144
|
-
If you are using Rails, put your Capybara specs in `spec/features` (only works
|
150
|
+
If you are using Rails, put your Capybara specs in `spec/features` or `spec/system` (only works
|
145
151
|
if [you have it configured in
|
146
152
|
RSpec](https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#file-type-inference-disabled))
|
147
153
|
and if you have your Capybara specs in a different directory, then tag the
|
148
|
-
example groups with
|
154
|
+
example groups with `type: :feature` or `type: :system` depending on which type of test you're writing.
|
149
155
|
|
150
156
|
If you are not using Rails, tag all the example groups in which you want to use
|
151
|
-
Capybara with
|
157
|
+
Capybara with `type: :feature`.
|
152
158
|
|
153
159
|
You can now write your specs like so:
|
154
160
|
|
155
161
|
```ruby
|
156
|
-
describe "the signin process", :
|
162
|
+
describe "the signin process", type: :feature do
|
157
163
|
before :each do
|
158
164
|
User.make(email: 'user@example.com', password: 'password')
|
159
165
|
end
|
@@ -177,7 +183,7 @@ to one specific driver. For example:
|
|
177
183
|
```ruby
|
178
184
|
describe 'some stuff which requires js', js: true do
|
179
185
|
it 'will use the default js driver'
|
180
|
-
it 'will switch to one specific driver', :
|
186
|
+
it 'will switch to one specific driver', driver: :webkit
|
181
187
|
end
|
182
188
|
```
|
183
189
|
|
@@ -213,11 +219,11 @@ feature "Signing in" do
|
|
213
219
|
end
|
214
220
|
```
|
215
221
|
|
216
|
-
`feature` is in fact just an alias for `describe ...,
|
222
|
+
`feature` is in fact just an alias for `describe ..., type:> :feature`,
|
217
223
|
`background` is an alias for `before`, `scenario` for `it`, and
|
218
224
|
`given`/`given!` aliases for `let`/`let!`, respectively.
|
219
225
|
|
220
|
-
Finally, Capybara matchers are supported in view specs:
|
226
|
+
Finally, Capybara matchers are also supported in view specs:
|
221
227
|
|
222
228
|
```ruby
|
223
229
|
RSpec.describe "todos/show.html.erb", type: :view do
|
@@ -543,7 +549,7 @@ If you find yourself needing to use this a lot you may be better off adding a [c
|
|
543
549
|
```ruby
|
544
550
|
find_field('First Name'){ |el| el['data-xyz'] == '123' }
|
545
551
|
find("#img_loading"){ |img| img['complete'] == true }
|
546
|
-
|
552
|
+
```
|
547
553
|
|
548
554
|
**Note**: `find` will wait for an element to appear on the page, as explained in the
|
549
555
|
Ajax section. If the element does not appear it will raise an error.
|
@@ -736,7 +742,7 @@ Capybara 1.x, set `Capybara.match` to `:prefer_exact`.
|
|
736
742
|
|
737
743
|
## <a name="transactions-and-database-setup"></a>Transactions and database setup
|
738
744
|
|
739
|
-
**Note:** Rails 5.1+
|
745
|
+
**Note:** Rails 5.1+ "safely" shares the database connection between the app and test threads. Therefore,
|
740
746
|
if using Rails 5.1+ you SHOULD be able to ignore this section.
|
741
747
|
|
742
748
|
Some Capybara drivers need to run against an actual HTTP server. Capybara takes
|
@@ -888,7 +894,7 @@ To permanently switch the current session to a different session
|
|
888
894
|
|
889
895
|
```ruby
|
890
896
|
Capybara.session_name = "some other session"
|
891
|
-
|
897
|
+
```
|
892
898
|
|
893
899
|
### <a name="using-sessions-manually"></a>Using sessions manually
|
894
900
|
|
@@ -1041,13 +1047,15 @@ additional info about how the underlying driver can be configured.
|
|
1041
1047
|
are testing for specific server errors and using multiple sessions make sure to test for the
|
1042
1048
|
errors using the initial session (usually :default)
|
1043
1049
|
|
1044
|
-
## <a name="threadsafe"></a>"Threadsafe" mode
|
1050
|
+
## <a name="threadsafe"></a>"Threadsafe" mode
|
1045
1051
|
|
1046
1052
|
In normal mode most of Capybara's configuration options are global settings which can cause issues
|
1047
1053
|
if using multiple sessions and wanting to change a setting for only one of the sessions. To provide
|
1048
1054
|
support for this type of usage Capybara now provides a "threadsafe" mode which can be enabled by setting
|
1049
1055
|
|
1050
|
-
|
1056
|
+
```ruby
|
1057
|
+
Capybara.threadsafe = true
|
1058
|
+
```
|
1051
1059
|
|
1052
1060
|
This setting can only be changed before any sessions have been created. In "threadsafe" mode the following
|
1053
1061
|
behaviors of Capybara change
|
@@ -1057,11 +1065,13 @@ behaviors of Capybara change
|
|
1057
1065
|
`app`, `reuse_server`, `default_driver`, `javascript_driver`, and (obviously) `threadsafe`. Any drivers and servers
|
1058
1066
|
registered through `register_driver` and `register_server` are also global.
|
1059
1067
|
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1068
|
+
```ruby
|
1069
|
+
my_session = Capybara::Session.new(:driver, some_app) do |config|
|
1070
|
+
config.automatic_label_click = true # only set for my_session
|
1071
|
+
end
|
1072
|
+
my_session.config.default_max_wait_time = 10 # only set for my_session
|
1073
|
+
Capybara.default_max_wait_time = 2 # will not change the default_max_wait in my_session
|
1074
|
+
```
|
1065
1075
|
|
1066
1076
|
* `current_driver` and `session_name` are thread specific. This means that `using_session` and
|
1067
1077
|
`using_driver` also only affect the current thread.
|
@@ -1072,7 +1082,8 @@ To set up a development environment, simply do:
|
|
1072
1082
|
|
1073
1083
|
```bash
|
1074
1084
|
bundle install
|
1075
|
-
bundle exec rake # run the test suite
|
1085
|
+
bundle exec rake # run the test suite with Firefox - requires `geckodriver` to be installed
|
1086
|
+
bundle exec rake spec_chrome # run the test suite with Chrome - require `chromedriver` to be installed
|
1076
1087
|
```
|
1077
1088
|
|
1078
1089
|
See
|
data/lib/capybara/config.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'forwardable'
|
3
4
|
require 'capybara/session/config'
|
4
5
|
|
@@ -6,7 +7,7 @@ module Capybara
|
|
6
7
|
class Config
|
7
8
|
extend Forwardable
|
8
9
|
|
9
|
-
OPTIONS = [
|
10
|
+
OPTIONS = %i[app reuse_server threadsafe default_wait_time server default_driver javascript_driver].freeze
|
10
11
|
|
11
12
|
attr_accessor :app
|
12
13
|
attr_reader :reuse_server, :threadsafe
|
@@ -21,12 +22,9 @@ module Capybara
|
|
21
22
|
@session_options = Capybara::SessionConfig.new
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
@reuse_server = bool
|
26
|
-
end
|
25
|
+
attr_writer :reuse_server
|
27
26
|
|
28
27
|
def threadsafe=(bool)
|
29
|
-
warn "Capybara.threadsafe == true is a BETA feature and may change in future minor versions" if bool
|
30
28
|
raise "Threadsafe setting cannot be changed once a session is created" if (bool != threadsafe) && Session.instance_created?
|
31
29
|
@threadsafe = bool
|
32
30
|
end
|
@@ -35,16 +33,9 @@ module Capybara
|
|
35
33
|
#
|
36
34
|
# Return the proc that Capybara will call to run the Rack application.
|
37
35
|
# The block returned receives a rack app, port, and host/ip and should run a Rack handler
|
38
|
-
# By default, Capybara will try to
|
36
|
+
# By default, Capybara will try to use puma.
|
39
37
|
#
|
40
|
-
|
41
|
-
if block_given?
|
42
|
-
warn "DEPRECATED: Passing a block to Capybara::server is deprecated, please use Capybara::register_server instead"
|
43
|
-
@server = block
|
44
|
-
else
|
45
|
-
@server
|
46
|
-
end
|
47
|
-
end
|
38
|
+
attr_reader :server
|
48
39
|
|
49
40
|
##
|
50
41
|
#
|
@@ -62,14 +53,10 @@ module Capybara
|
|
62
53
|
#
|
63
54
|
def server=(name)
|
64
55
|
name, options = *name if name.is_a? Array
|
65
|
-
@server = if
|
66
|
-
name
|
56
|
+
@server = if options
|
57
|
+
proc { |app, port, host| Capybara.servers[name.to_sym].call(app, port, host, options) }
|
67
58
|
else
|
68
|
-
|
69
|
-
Proc.new { |app, port, host| Capybara.servers[name.to_sym].call(app,port,host,options) }
|
70
|
-
else
|
71
|
-
Capybara.servers[name.to_sym]
|
72
|
-
end
|
59
|
+
Capybara.servers[name.to_sym]
|
73
60
|
end
|
74
61
|
end
|
75
62
|
|
@@ -89,43 +76,10 @@ module Capybara
|
|
89
76
|
@javascript_driver || :selenium
|
90
77
|
end
|
91
78
|
|
92
|
-
|
93
|
-
def default_wait_time
|
94
|
-
deprecate('default_wait_time', 'default_max_wait_time', true)
|
95
|
-
default_max_wait_time
|
96
|
-
end
|
97
|
-
|
98
|
-
# @deprecated Use default_max_wait_time= instead
|
99
|
-
def default_wait_time=(t)
|
100
|
-
deprecate('default_wait_time=', 'default_max_wait_time=')
|
101
|
-
self.default_max_wait_time = t
|
102
|
-
end
|
103
|
-
|
104
|
-
def deprecate(method, alternate_method, once=false)
|
79
|
+
def deprecate(method, alternate_method, once = false)
|
105
80
|
@deprecation_notified ||= {}
|
106
81
|
warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead" unless once and @deprecation_notified[method]
|
107
|
-
@deprecation_notified[method]=true
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
class ConfigureDeprecator
|
112
|
-
def initialize(config)
|
113
|
-
@config = config
|
114
|
-
end
|
115
|
-
|
116
|
-
def method_missing(m, *args, &block)
|
117
|
-
if @config.respond_to?(m)
|
118
|
-
@config.public_send(m, *args, &block)
|
119
|
-
elsif Capybara.respond_to?(m)
|
120
|
-
warn "Calling #{m} from Capybara.configure is deprecated - please call it on Capybara directly ( Capybara.#{m}(...) )"
|
121
|
-
Capybara.public_send(m, *args, &block)
|
122
|
-
else
|
123
|
-
super
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def respond_to_missing?(m, include_private = false)
|
128
|
-
@config.respond_to_missing?(m, include_private) || Capybara.respond_to_missing?(m, include_private)
|
82
|
+
@deprecation_notified[method] = true
|
129
83
|
end
|
130
84
|
end
|
131
|
-
end
|
85
|
+
end
|
data/lib/capybara/cucumber.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'capybara/dsl'
|
3
4
|
require 'capybara/rspec/matchers'
|
4
5
|
require 'capybara/rspec/matcher_proxies'
|
@@ -21,8 +22,6 @@ end
|
|
21
22
|
Before do |scenario|
|
22
23
|
scenario.source_tag_names.each do |tag|
|
23
24
|
driver_name = tag.sub(/^@/, '').to_sym
|
24
|
-
if Capybara.drivers.
|
25
|
-
Capybara.current_driver = driver_name
|
26
|
-
end
|
25
|
+
Capybara.current_driver = driver_name if Capybara.drivers.key?(driver_name)
|
27
26
|
end
|
28
27
|
end
|
data/lib/capybara/driver/base.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Capybara::Driver::Base
|
3
4
|
attr_writer :session
|
4
5
|
|
@@ -42,7 +43,11 @@ class Capybara::Driver::Base
|
|
42
43
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#evaluate_script'
|
43
44
|
end
|
44
45
|
|
45
|
-
def
|
46
|
+
def evaluate_async_script(script, *args)
|
47
|
+
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#evaluate_script_asnyc'
|
48
|
+
end
|
49
|
+
|
50
|
+
def save_screenshot(path, **options)
|
46
51
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#save_screenshot'
|
47
52
|
end
|
48
53
|
|
@@ -62,6 +67,16 @@ class Capybara::Driver::Base
|
|
62
67
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#switch_to_frame'
|
63
68
|
end
|
64
69
|
|
70
|
+
def frame_title
|
71
|
+
find_xpath('/html/head/title').map(&:all_text).first.to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
def frame_url
|
75
|
+
evaluate_script('document.location.href')
|
76
|
+
rescue Capybara::NotSupportedByDriverError
|
77
|
+
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#frame_title'
|
78
|
+
end
|
79
|
+
|
65
80
|
def current_window_handle
|
66
81
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#current_window_handle'
|
67
82
|
end
|
@@ -94,15 +109,10 @@ class Capybara::Driver::Base
|
|
94
109
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#switch_to_window'
|
95
110
|
end
|
96
111
|
|
97
|
-
def within_window(locator)
|
98
|
-
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#within_window'
|
99
|
-
end
|
100
|
-
|
101
112
|
def no_such_window_error
|
102
113
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#no_such_window_error'
|
103
114
|
end
|
104
115
|
|
105
|
-
|
106
116
|
##
|
107
117
|
#
|
108
118
|
# Execute the block, and then accept the modal opened.
|
@@ -113,7 +123,7 @@ class Capybara::Driver::Base
|
|
113
123
|
# @return [String] the message shown in the modal
|
114
124
|
# @raise [Capybara::ModalNotFound] if modal dialog hasn't been found
|
115
125
|
#
|
116
|
-
def accept_modal(type, options
|
126
|
+
def accept_modal(type, **options, &blk)
|
117
127
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#accept_modal'
|
118
128
|
end
|
119
129
|
|
@@ -126,7 +136,7 @@ class Capybara::Driver::Base
|
|
126
136
|
# @return [String] the message shown in the modal
|
127
137
|
# @raise [Capybara::ModalNotFound] if modal dialog hasn't been found
|
128
138
|
#
|
129
|
-
def dismiss_modal(type, options
|
139
|
+
def dismiss_modal(type, **options, &blk)
|
130
140
|
raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#dismiss_modal'
|
131
141
|
end
|
132
142
|
|
@@ -138,8 +148,7 @@ class Capybara::Driver::Base
|
|
138
148
|
false
|
139
149
|
end
|
140
150
|
|
141
|
-
def reset
|
142
|
-
end
|
151
|
+
def reset!; end
|
143
152
|
|
144
153
|
def needs_server?
|
145
154
|
false
|
@@ -148,10 +157,4 @@ class Capybara::Driver::Base
|
|
148
157
|
def session_options
|
149
158
|
(@session && @session.config) || Capybara.session_options
|
150
159
|
end
|
151
|
-
|
152
|
-
# @deprecated This method is being removed
|
153
|
-
def browser_initialized?
|
154
|
-
warn "DEPRECATED: #browser_initialized? is deprecated and will be removed in the next version of Capybara"
|
155
|
-
true
|
156
|
-
end
|
157
160
|
end
|
data/lib/capybara/driver/node.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Capybara
|
3
4
|
module Driver
|
4
5
|
class Node
|
@@ -27,7 +28,7 @@ module Capybara
|
|
27
28
|
|
28
29
|
# @param value String or Array. Array is only allowed if node has 'multiple' attribute
|
29
30
|
# @param options [Hash{}] Driver specific options for how to set a value on a node
|
30
|
-
def set(value, options
|
31
|
+
def set(value, **options)
|
31
32
|
raise NotImplementedError
|
32
33
|
end
|
33
34
|
|
@@ -39,15 +40,15 @@ module Capybara
|
|
39
40
|
raise NotImplementedError
|
40
41
|
end
|
41
42
|
|
42
|
-
def click
|
43
|
+
def click(keys = [], options = {})
|
43
44
|
raise NotImplementedError
|
44
45
|
end
|
45
46
|
|
46
|
-
def right_click
|
47
|
+
def right_click(keys = [], options = {})
|
47
48
|
raise NotImplementedError
|
48
49
|
end
|
49
50
|
|
50
|
-
def double_click
|
51
|
+
def double_click(keys = [], options = {})
|
51
52
|
raise NotImplementedError
|
52
53
|
end
|
53
54
|
|