capybara 2.4.4 → 2.5.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 +32 -5
- data/README.md +69 -8
- data/lib/capybara.rb +50 -29
- data/lib/capybara/driver/base.rb +4 -0
- data/lib/capybara/driver/node.rb +4 -0
- data/lib/capybara/helpers.rb +17 -5
- data/lib/capybara/node/actions.rb +16 -11
- data/lib/capybara/node/base.rb +7 -7
- data/lib/capybara/node/document_matchers.rb +1 -1
- data/lib/capybara/node/element.rb +82 -7
- data/lib/capybara/node/finders.rb +62 -22
- data/lib/capybara/node/matchers.rb +3 -3
- data/lib/capybara/node/simple.rb +6 -1
- data/lib/capybara/queries/base_query.rb +1 -1
- data/lib/capybara/queries/current_path_query.rb +58 -0
- data/lib/capybara/queries/text_query.rb +2 -11
- data/lib/capybara/rack_test/browser.rb +7 -2
- data/lib/capybara/rack_test/driver.rb +4 -0
- data/lib/capybara/rack_test/form.rb +2 -1
- data/lib/capybara/rack_test/node.rb +1 -0
- data/lib/capybara/result.rb +2 -2
- data/lib/capybara/rspec.rb +1 -0
- data/lib/capybara/rspec/features.rb +1 -1
- data/lib/capybara/rspec/matchers.rb +42 -3
- data/lib/capybara/selector.rb +7 -2
- data/lib/capybara/selenium/driver.rb +26 -12
- data/lib/capybara/selenium/node.rb +42 -6
- data/lib/capybara/server.rb +1 -1
- data/lib/capybara/session.rb +78 -50
- data/lib/capybara/session/matchers.rb +69 -0
- data/lib/capybara/spec/public/test.js +8 -0
- data/lib/capybara/spec/session/all_spec.rb +5 -0
- data/lib/capybara/spec/session/assert_current_path.rb +59 -0
- data/lib/capybara/spec/session/assert_text.rb +1 -1
- data/lib/capybara/spec/session/attach_file_spec.rb +2 -2
- data/lib/capybara/spec/session/body_spec.rb +2 -0
- data/lib/capybara/spec/session/click_button_spec.rb +17 -8
- data/lib/capybara/spec/session/click_link_spec.rb +32 -1
- data/lib/capybara/spec/session/current_url_spec.rb +5 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +1 -1
- data/lib/capybara/spec/session/find_field_spec.rb +17 -0
- data/lib/capybara/spec/session/find_spec.rb +14 -5
- data/lib/capybara/spec/session/first_spec.rb +24 -0
- data/lib/capybara/spec/session/has_current_path_spec.rb +68 -0
- data/lib/capybara/spec/session/has_link_spec.rb +3 -0
- data/lib/capybara/spec/session/has_text_spec.rb +7 -0
- data/lib/capybara/spec/session/node_spec.rb +45 -6
- data/lib/capybara/spec/session/reset_session_spec.rb +18 -1
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +19 -0
- data/lib/capybara/spec/session/save_page_spec.rb +12 -3
- data/lib/capybara/spec/session/save_screenshot_spec.rb +23 -0
- data/lib/capybara/spec/session/select_spec.rb +12 -0
- data/lib/capybara/spec/session/title_spec.rb +2 -2
- data/lib/capybara/spec/session/window/become_closed_spec.rb +4 -4
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +8 -0
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +14 -8
- data/lib/capybara/spec/session/window/window_spec.rb +24 -4
- data/lib/capybara/spec/spec_helper.rb +3 -1
- data/lib/capybara/spec/test_app.rb +10 -1
- data/lib/capybara/spec/views/form.erb +7 -1
- data/lib/capybara/spec/views/path.erb +12 -0
- data/lib/capybara/spec/views/with_html.erb +2 -0
- data/lib/capybara/spec/views/with_js.erb +9 -1
- data/lib/capybara/spec/views/with_title.erb +4 -1
- data/lib/capybara/spec/views/with_windows.erb +2 -2
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +1 -0
- data/spec/capybara_spec.rb +12 -3
- data/spec/dsl_spec.rb +18 -6
- data/spec/rack_test_spec.rb +6 -5
- data/spec/rspec/matchers_spec.rb +62 -16
- data/spec/rspec/views_spec.rb +7 -0
- data/spec/selenium_spec.rb +38 -3
- data/spec/selenium_spec_chrome.rb +3 -7
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3213dfe8f170fe23b4374001be7b721b00ce9ff7
|
4
|
+
data.tar.gz: aaebf44440aff65f3183728e404bb07660e606e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1624de546eb1f2f56b5dfc38a8a4f597aa930d1db0101ce6f712deb7d15abc31845385b4b18971cfe0d76328d45c8c478109af1de1584c86c64a4f6c30dc550c
|
7
|
+
data.tar.gz: 21b3438ac351b7a70d642001fb15e429fac7ff3df7eb01f56c04141c5e603bf12dfb1368a408924ee9d6ebb0450cc8397bcab92d4eb9b9242eaac63d7390808e
|
data/History.md
CHANGED
@@ -1,14 +1,41 @@
|
|
1
|
+
# Version 2.5.0
|
2
|
+
Release date: 2015-08-25
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
* Error message now raised correctly when invalid options passed to 'have_text'/'have_content' [Tom Walpole]
|
6
|
+
* Rack-test driver correctly gets document title when elements on the page have nested title elements (SVG) [Tom Walpole]
|
7
|
+
* 'save_page' no longer errors when using Capybara.asset_host if the page has no \<head> element [Travis Grathwell]
|
8
|
+
* rack-test driver will ignore clicks on links with href starting with '#' or 'javascript:'
|
9
|
+
|
10
|
+
### Added
|
11
|
+
* has_current_path? and associated asserts/matchers added [Tom Walpole]
|
12
|
+
* Implement Node#path in selenium driver [Soutaro Matsumoto]
|
13
|
+
* 'using_session' is now nestable [Tom Walpole]
|
14
|
+
* 'switch_to_window' will now use waiting behavior for a matching window to appear [Tom Walpole]
|
15
|
+
* Capybara.default_wait_time deprecated in favor of Capybara.default_max_wait_time to more clearly explain its purpose [Paul Pettengill]
|
16
|
+
* Warning when attempting to select a disabled option
|
17
|
+
* Capybara matchers are now available in RSpec view specs by default [Joshua Clayton]
|
18
|
+
* 'have_link' and 'click_link' now accept Regexp for href matching [Yaniv Savir]
|
19
|
+
* 'find_all' as an alias of 'all' due to collision with RSpec
|
20
|
+
* Capybara.wait_on_first_by_default setting (default is false)
|
21
|
+
If set to true 'first' will use Capybaras waiting behavior to wait for at least one element to appear by default
|
22
|
+
* Capybara waiting behavior uses the monotonic clock if supported to ease restrictions on freezing time in tests [Dmitry Maksyoma, Tom Walpole]
|
23
|
+
* Capybara.server_errors setting that allows to configure what type of errors will be raised from the server thread [Tom Walpole]
|
24
|
+
* Node#send_keys to allow for sending keypresses directly to elements [Tom Walpole]
|
25
|
+
* 'formmethod' attribute support in RackTest driver [Emilia Andrzejewska]
|
26
|
+
* Clear field using backspaces in Selenium driver by using `:fill_options => { :clear => :backspace }` [Joe Lencioni]
|
27
|
+
|
1
28
|
#Version 2.4.4
|
2
|
-
Release
|
29
|
+
Release date: 2014-10-13
|
3
30
|
|
4
|
-
###Fixed
|
31
|
+
### Fixed
|
5
32
|
* Test for visit behavior updated [Phil Baker]
|
6
33
|
* Removed concurrency prevention in favor of a note in the README - due to load order issues
|
7
34
|
|
8
35
|
# Version 2.4.3
|
9
36
|
Relase date: 2014-09-21
|
10
37
|
|
11
|
-
###Fixed
|
38
|
+
### Fixed
|
12
39
|
* Update concurrency prevention to match Rails 4.2 behavior
|
13
40
|
|
14
41
|
# Version 2.4.2
|
@@ -31,7 +58,7 @@ Release date: 2014-07-03
|
|
31
58
|
* have_title matcher now supports :wait option [Andrey Botalov]
|
32
59
|
* More descriptive have_text error messages [Andrey Botalov]
|
33
60
|
* New modal API ('accept_alert', 'accept_confirm', 'dismiss_confirm', 'accept_prompt', 'dismiss_prompt') - [Mike Pack, Thomas Walpole]
|
34
|
-
* Warning when attempting to set contents of a readonly element
|
61
|
+
* Warning when attempting to set contents of a readonly element
|
35
62
|
* Suport for and/or compounding of Capybara's RSpec matchers for RSpec 3 [Thomas Walpole]
|
36
63
|
* :fill_options option for 'fill_in' method that propagates to 'set' to allow for driver specific modification of how fields are filled in [Gabriel Sobrinho, Thomas Walpole]
|
37
64
|
* Improved selector/filter description in failure messages [Thomas Walpole]
|
@@ -309,7 +336,7 @@ Release date: 2012-11-05
|
|
309
336
|
* `Node#synchronize` method to rerun a block of code if certain errors are raised
|
310
337
|
[Jonas Nicklas]
|
311
338
|
* `Capybara.always_include_port` config option always includes the server port in
|
312
|
-
URLs when using `visit`. Facilitates testing different domain names
|
339
|
+
URLs when using `visit`. Facilitates testing different domain names. [Douwe Maan]
|
313
340
|
* Redirect limit for RackTest driver is configurable [Josh Lane]
|
314
341
|
* Server port can be manually specified during initialization of server.
|
315
342
|
[Jonas Nicklas, John Wilger]
|
data/README.md
CHANGED
@@ -12,6 +12,45 @@ through an external gem.
|
|
12
12
|
**Need help?** Ask on the mailing list (please do not open an issue on
|
13
13
|
GitHub): http://groups.google.com/group/ruby-capybara
|
14
14
|
|
15
|
+
## Table of contents
|
16
|
+
|
17
|
+
- [Key benefits](#key-benefits)
|
18
|
+
- [Setup](#setup)
|
19
|
+
- [Using Capybara with Cucumber](#using-capybara-with-cucumber)
|
20
|
+
- [Using Capybara with RSpec](#using-capybara-with-rspec)
|
21
|
+
- [Using Capybara with Test::Unit](#using-capybara-with-testunit)
|
22
|
+
- [Using Capybara with MiniTest::Spec](#using-capybara-with-minitestspec)
|
23
|
+
- [Drivers](#drivers)
|
24
|
+
- [Selecting the Driver](#selecting-the-driver)
|
25
|
+
- [RackTest](#racktest)
|
26
|
+
- [Selenium](#selenium)
|
27
|
+
- [Capybara-webkit](#capybara-webkit)
|
28
|
+
- [Poltergeist](#poltergeist)
|
29
|
+
- [The DSL](#the-dsl)
|
30
|
+
- [Navigating](#navigating)
|
31
|
+
- [Clicking links and buttons](#clicking-links-and-buttons)
|
32
|
+
- [Interacting with forms](#interacting-with-forms)
|
33
|
+
- [Querying](#querying)
|
34
|
+
- [Finding](#finding)
|
35
|
+
- [Scoping](#scoping)
|
36
|
+
- [Working with windows](#working-with-windows)
|
37
|
+
- [Scripting](#scripting)
|
38
|
+
- [Modals](#modals)
|
39
|
+
- [Debugging](#debugging)
|
40
|
+
- [Matching](#matching)
|
41
|
+
- [Exactness](#exactness)
|
42
|
+
- [Strategy](#strategy)
|
43
|
+
- [Transactions and database setup](#transactions-and-database-setup)
|
44
|
+
- [Asynchronous JavaScript (Ajax and friends)](#asynchronous-javascript-ajax-and-friends)
|
45
|
+
- [Using the DSL elsewhere](#using-the-dsl-elsewhere)
|
46
|
+
- [Calling remote servers](#calling-remote-servers)
|
47
|
+
- [Using the sessions manually](#using-the-sessions-manually)
|
48
|
+
- [XPath, CSS and selectors](#xpath-css-and-selectors)
|
49
|
+
- [Beware the XPath // trap](#beware-the-xpath--trap)
|
50
|
+
- [Configuring and adding drivers](#configuring-and-adding-drivers)
|
51
|
+
- [Gotchas:](#gotchas)
|
52
|
+
- [Development](#development)
|
53
|
+
|
15
54
|
## Key benefits
|
16
55
|
|
17
56
|
- **No setup** necessary for Rails and Rack application. Works out of the box.
|
@@ -36,8 +75,8 @@ If the application that you are testing is a Rails app, add this line to your te
|
|
36
75
|
require 'capybara/rails'
|
37
76
|
```
|
38
77
|
|
39
|
-
Note
|
40
|
-
If you experience random errors about missing constants,
|
78
|
+
**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).
|
79
|
+
If you experience random errors about missing constants, add `config.allow_concurrency = false` to `config/environments/test.rb`.
|
41
80
|
|
42
81
|
If the application that you are testing is a Rack app, but not Rails, set Capybara.app to your Rack app:
|
43
82
|
|
@@ -102,7 +141,7 @@ You can now write your specs like so:
|
|
102
141
|
```ruby
|
103
142
|
describe "the signin process", :type => :feature do
|
104
143
|
before :each do
|
105
|
-
User.make(:email => 'user@example.com', :password => '
|
144
|
+
User.make(:email => 'user@example.com', :password => 'password')
|
106
145
|
end
|
107
146
|
|
108
147
|
it "signs me in" do
|
@@ -128,7 +167,7 @@ describe 'some stuff which requires js', :js => true do
|
|
128
167
|
end
|
129
168
|
```
|
130
169
|
|
131
|
-
|
170
|
+
Capybara also comes with a built in DSL for creating descriptive acceptance tests:
|
132
171
|
|
133
172
|
```ruby
|
134
173
|
feature "Signing in" do
|
@@ -164,6 +203,20 @@ end
|
|
164
203
|
`background` is an alias for `before`, `scenario` for `it`, and
|
165
204
|
`given`/`given!` aliases for `let`/`let!`, respectively.
|
166
205
|
|
206
|
+
Finally, Capybara matchers are supported in view specs:
|
207
|
+
|
208
|
+
```ruby
|
209
|
+
RSpec.describe "todos/show.html.erb", type: :view do
|
210
|
+
it "displays the todo title" do
|
211
|
+
assign :todo, Todo.new(title: "Buy milk")
|
212
|
+
|
213
|
+
render
|
214
|
+
|
215
|
+
expect(rendered).to have_css("header h1", text: "Buy milk")
|
216
|
+
end
|
217
|
+
end
|
218
|
+
```
|
219
|
+
|
167
220
|
## Using Capybara with Test::Unit
|
168
221
|
|
169
222
|
* If you are using Rails, add the following code in your `test_helper.rb`
|
@@ -249,7 +302,7 @@ After/teardown blocks):
|
|
249
302
|
|
250
303
|
```ruby
|
251
304
|
Capybara.current_driver = :webkit # temporarily select different driver
|
252
|
-
|
305
|
+
# tests here
|
253
306
|
Capybara.use_default_driver # switch back to default driver
|
254
307
|
```
|
255
308
|
|
@@ -325,6 +378,9 @@ any Javascript errors that happen within the page.
|
|
325
378
|
*A complete reference is available at
|
326
379
|
[rubydoc.info](http://rubydoc.info/github/jnicklas/capybara/master)*.
|
327
380
|
|
381
|
+
**Note: By default Capybara will only locate visible elements. This is because
|
382
|
+
a real user would not be able to interact with non-visible elements.**
|
383
|
+
|
328
384
|
**Note**: All searches in Capybara are *case sensitive*. This is because
|
329
385
|
Capybara heavily uses XPath, which doesn't support case insensitivity.
|
330
386
|
|
@@ -419,7 +475,7 @@ You can also find specific elements, in order to manipulate them:
|
|
419
475
|
|
420
476
|
```ruby
|
421
477
|
find_field('First Name').value
|
422
|
-
find_link('Hello').visible?
|
478
|
+
find_link('Hello', :visible => :all).visible?
|
423
479
|
find_button('Send').click
|
424
480
|
|
425
481
|
find(:xpath, "//table/tr").click
|
@@ -670,7 +726,7 @@ looking for that content for a brief time. You can adjust how long this period
|
|
670
726
|
is (the default is 2 seconds):
|
671
727
|
|
672
728
|
```ruby
|
673
|
-
Capybara.
|
729
|
+
Capybara.default_max_wait_time = 5
|
674
730
|
```
|
675
731
|
|
676
732
|
Be aware that because of this behaviour, the following two statements are **not**
|
@@ -896,7 +952,8 @@ additional info about how the underlying driver can be configured.
|
|
896
952
|
since we're not using Rails' integration testing.
|
897
953
|
|
898
954
|
* Freezing time: It's common practice to mock out the Time so that features
|
899
|
-
that depend on the current Date work as expected. This can be problematic
|
955
|
+
that depend on the current Date work as expected. This can be problematic on
|
956
|
+
ruby/platform combinations that don't support access to a monotonic process clock,
|
900
957
|
since Capybara's Ajax timing uses the system time, resulting in Capybara
|
901
958
|
never timing out and just hanging when a failure occurs. It's still possible to
|
902
959
|
use gems which allow you to travel in time, rather than freeze time.
|
@@ -908,6 +965,10 @@ additional info about how the underlying driver can be configured.
|
|
908
965
|
set `default_url_options` to match the Rails default of
|
909
966
|
`www.example.com`.
|
910
967
|
|
968
|
+
* Server errors will only be raised in the session that initiates the server thread. If you
|
969
|
+
are testing for specific server errors and using multiple sessions make sure to test for the
|
970
|
+
errors using the initial session (usually :default)
|
971
|
+
|
911
972
|
## Development
|
912
973
|
|
913
974
|
To set up a development environment, simply do:
|
data/lib/capybara.rb
CHANGED
@@ -21,8 +21,8 @@ module Capybara
|
|
21
21
|
class << self
|
22
22
|
attr_accessor :asset_host, :app_host, :run_server, :default_host, :always_include_port
|
23
23
|
attr_accessor :server_port, :exact, :match, :exact_options, :visible_text_only
|
24
|
-
attr_accessor :default_selector, :
|
25
|
-
attr_accessor :save_and_open_page_path, :automatic_reload, :raise_server_errors
|
24
|
+
attr_accessor :default_selector, :default_max_wait_time, :ignore_hidden_elements
|
25
|
+
attr_accessor :save_and_open_page_path, :wait_on_first_by_default, :automatic_reload, :raise_server_errors, :server_errors
|
26
26
|
attr_writer :default_driver, :current_driver, :javascript_driver, :session_name, :server_host
|
27
27
|
attr_accessor :app
|
28
28
|
|
@@ -37,22 +37,24 @@ module Capybara
|
|
37
37
|
#
|
38
38
|
# === Configurable options
|
39
39
|
#
|
40
|
-
# [app_host = String] The default host to use when giving a relative URL to visit
|
41
|
-
# [always_include_port = Boolean] Whether the Rack server's port should automatically be inserted into every visited URL (Default: false)
|
42
|
-
# [asset_host = String] Where dynamic assets are hosted - will be prepended to relative asset locations if present (Default: nil)
|
43
|
-
# [run_server = Boolean] Whether to start a Rack server for the given Rack app (Default: true)
|
44
|
-
# [
|
45
|
-
# [
|
46
|
-
# [
|
47
|
-
# [
|
48
|
-
# [
|
49
|
-
#
|
40
|
+
# [app_host = String] The default host to use when giving a relative URL to visit
|
41
|
+
# [always_include_port = Boolean] Whether the Rack server's port should automatically be inserted into every visited URL (Default: false)
|
42
|
+
# [asset_host = String] Where dynamic assets are hosted - will be prepended to relative asset locations if present (Default: nil)
|
43
|
+
# [run_server = Boolean] Whether to start a Rack server for the given Rack app (Default: true)
|
44
|
+
# [raise_server_errors = Boolean] Should errors raised in the server be raised in the tests? (Default: true)
|
45
|
+
# [server_errors = Array\<Class\>] Error classes that should be raised in the tests if they are raised in the server and Capybara.raise_server_errors is true (Default: [StandardError])
|
46
|
+
# [default_selector = :css/:xpath] Methods which take a selector use the given type by default (Default: :css)
|
47
|
+
# [default_max_wait_time = Numeric] The maximum number of seconds to wait for asynchronous processes to finish (Default: 2)
|
48
|
+
# [ignore_hidden_elements = Boolean] Whether to ignore hidden elements on the page (Default: true)
|
49
|
+
# [automatic_reload = Boolean] Whether to automatically reload elements as Capybara is waiting (Default: true)
|
50
|
+
# [save_and_open_page_path = String] Where to put pages saved through save_and_open_page (Default: Dir.pwd)
|
51
|
+
# [wait_on_first_by_default = Boolean] Whether Node#first defaults to Capybara waiting behavior for at least 1 element to match (Default: false)
|
50
52
|
# === DSL Options
|
51
53
|
#
|
52
54
|
# when using capybara/dsl, the following options are also available:
|
53
55
|
#
|
54
|
-
# [default_driver = Symbol] The name of the driver to use by default. (Default: :rack_test)
|
55
|
-
# [javascript_driver = Symbol] The name of a driver to use for JavaScript enabled tests. (Default: :selenium)
|
56
|
+
# [default_driver = Symbol] The name of the driver to use by default. (Default: :rack_test)
|
57
|
+
# [javascript_driver = Symbol] The name of a driver to use for JavaScript enabled tests. (Default: :selenium)
|
56
58
|
#
|
57
59
|
def configure
|
58
60
|
yield self
|
@@ -63,12 +65,12 @@ module Capybara
|
|
63
65
|
# Register a new driver for Capybara.
|
64
66
|
#
|
65
67
|
# Capybara.register_driver :rack_test do |app|
|
66
|
-
# Capybara::Driver
|
68
|
+
# Capybara::RackTest::Driver.new(app)
|
67
69
|
# end
|
68
70
|
#
|
69
71
|
# @param [Symbol] name The name of the new driver
|
70
72
|
# @yield [app] This block takes a rack app and returns a Capybara driver
|
71
|
-
# @yieldparam [<Rack>] app The rack application that this driver runs
|
73
|
+
# @yieldparam [<Rack>] app The rack application that this driver runs against. May be nil.
|
72
74
|
# @yieldreturn [Capybara::Driver::Base] A Capybara driver instance
|
73
75
|
#
|
74
76
|
def register_driver(name, &block)
|
@@ -135,9 +137,9 @@ module Capybara
|
|
135
137
|
##
|
136
138
|
#
|
137
139
|
# Wraps the given string, which should contain an HTML document or fragment
|
138
|
-
# in a {Capybara::Node::Simple} which exposes all {Capybara::Node::Matchers}
|
139
|
-
# {Capybara::Node::Finders}. This allows you to query
|
140
|
-
# HTML in the exact same way you would query the current document in a Capybara
|
140
|
+
# in a {Capybara::Node::Simple} which exposes all {Capybara::Node::Matchers},
|
141
|
+
# {Capybara::Node::Finders} and {Capybara::Node::DocumentMatchers}. This allows you to query
|
142
|
+
# any string containing HTML in the exact same way you would query the current document in a Capybara
|
141
143
|
# session. For example:
|
142
144
|
#
|
143
145
|
# node = Capybara.string <<-HTML
|
@@ -149,8 +151,8 @@ module Capybara
|
|
149
151
|
#
|
150
152
|
# node.find('#projects').text # => 'Projects'
|
151
153
|
# node.has_selector?('li#home', :text => 'Home')
|
152
|
-
# node.has_selector?(
|
153
|
-
# node.find('ul').find('li').text # => 'Home'
|
154
|
+
# node.has_selector?('#projects')
|
155
|
+
# node.find('ul').find('li:first-child').text # => 'Home'
|
154
156
|
#
|
155
157
|
# @param [String] html An html fragment or document
|
156
158
|
# @return [Capybara::Node::Simple] A node which has Capybara's finders and matchers
|
@@ -231,11 +233,11 @@ module Capybara
|
|
231
233
|
# Yield a block using a specific wait time
|
232
234
|
#
|
233
235
|
def using_wait_time(seconds)
|
234
|
-
previous_wait_time = Capybara.
|
235
|
-
Capybara.
|
236
|
+
previous_wait_time = Capybara.default_max_wait_time
|
237
|
+
Capybara.default_max_wait_time = seconds
|
236
238
|
yield
|
237
239
|
ensure
|
238
|
-
Capybara.
|
240
|
+
Capybara.default_max_wait_time = previous_wait_time
|
239
241
|
end
|
240
242
|
|
241
243
|
##
|
@@ -273,10 +275,11 @@ module Capybara
|
|
273
275
|
# Yield a block using a specific session name.
|
274
276
|
#
|
275
277
|
def using_session(name)
|
278
|
+
previous_session_name = self.session_name
|
276
279
|
self.session_name = name
|
277
280
|
yield
|
278
281
|
ensure
|
279
|
-
self.session_name =
|
282
|
+
self.session_name = previous_session_name
|
280
283
|
end
|
281
284
|
|
282
285
|
##
|
@@ -293,14 +296,28 @@ module Capybara
|
|
293
296
|
end
|
294
297
|
end
|
295
298
|
end
|
299
|
+
|
300
|
+
# @deprecated Use default_max_wait_time instead
|
301
|
+
def default_wait_time
|
302
|
+
deprecate('default_wait_time', 'default_max_wait_time', true)
|
303
|
+
default_max_wait_time
|
304
|
+
end
|
305
|
+
|
306
|
+
# @deprecated Use default_max_wait_time= instead
|
307
|
+
def default_wait_time=(t)
|
308
|
+
deprecate('default_wait_time=', 'default_max_wait_time=')
|
309
|
+
self.default_max_wait_time = t
|
310
|
+
end
|
296
311
|
|
297
312
|
def included(base)
|
298
313
|
base.send(:include, Capybara::DSL)
|
299
314
|
warn "`include Capybara` is deprecated. Please use `include Capybara::DSL` instead."
|
300
315
|
end
|
301
316
|
|
302
|
-
def deprecate(method, alternate_method)
|
303
|
-
|
317
|
+
def deprecate(method, alternate_method, once=false)
|
318
|
+
@deprecation_notified ||= {}
|
319
|
+
warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead" unless once and @deprecation_notified[method]
|
320
|
+
@deprecation_notified[method]=true
|
304
321
|
end
|
305
322
|
|
306
323
|
private
|
@@ -312,6 +329,7 @@ module Capybara
|
|
312
329
|
|
313
330
|
self.default_driver = nil
|
314
331
|
self.current_driver = nil
|
332
|
+
self.server_host = nil
|
315
333
|
|
316
334
|
module Driver; end
|
317
335
|
module RackTest; end
|
@@ -330,7 +348,8 @@ module Capybara
|
|
330
348
|
require 'capybara/query'
|
331
349
|
require 'capybara/queries/text_query'
|
332
350
|
require 'capybara/queries/title_query'
|
333
|
-
|
351
|
+
require 'capybara/queries/current_path_query'
|
352
|
+
|
334
353
|
require 'capybara/node/finders'
|
335
354
|
require 'capybara/node/matchers'
|
336
355
|
require 'capybara/node/actions'
|
@@ -358,14 +377,16 @@ Capybara.configure do |config|
|
|
358
377
|
config.run_server = true
|
359
378
|
config.server {|app, port| Capybara.run_default_server(app, port)}
|
360
379
|
config.default_selector = :css
|
361
|
-
config.
|
380
|
+
config.default_max_wait_time = 2
|
362
381
|
config.ignore_hidden_elements = true
|
363
382
|
config.default_host = "http://www.example.com"
|
364
383
|
config.automatic_reload = true
|
365
384
|
config.match = :smart
|
366
385
|
config.exact = false
|
367
386
|
config.raise_server_errors = true
|
387
|
+
config.server_errors = [StandardError]
|
368
388
|
config.visible_text_only = false
|
389
|
+
config.wait_on_first_by_default = false
|
369
390
|
end
|
370
391
|
|
371
392
|
Capybara.register_driver :rack_test do |app|
|
data/lib/capybara/driver/base.rb
CHANGED
data/lib/capybara/driver/node.rb
CHANGED
data/lib/capybara/helpers.rb
CHANGED
@@ -40,12 +40,14 @@ module Capybara
|
|
40
40
|
# @return [String] The modified HTML code
|
41
41
|
#
|
42
42
|
def inject_asset_host(html)
|
43
|
-
if Capybara.asset_host && Nokogiri::HTML(html).css("base").empty?
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
if Capybara.asset_host && Nokogiri::HTML(html).css("base").empty?
|
44
|
+
match = html.match(/<head[^<]*?>/)
|
45
|
+
if match
|
46
|
+
return html.clone.insert match.end(0), "<base href='#{Capybara.asset_host}' />"
|
47
|
+
end
|
48
48
|
end
|
49
|
+
|
50
|
+
html
|
49
51
|
end
|
50
52
|
|
51
53
|
##
|
@@ -124,5 +126,15 @@ module Capybara
|
|
124
126
|
plural
|
125
127
|
end
|
126
128
|
end
|
129
|
+
|
130
|
+
if defined?(Process::CLOCK_MONOTONIC)
|
131
|
+
def monotonic_time
|
132
|
+
Process.clock_gettime Process::CLOCK_MONOTONIC
|
133
|
+
end
|
134
|
+
else
|
135
|
+
def monotonic_time
|
136
|
+
Time.now.to_f
|
137
|
+
end
|
138
|
+
end
|
127
139
|
end
|
128
140
|
end
|