capybara 2.4.4 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +32 -5
  3. data/README.md +69 -8
  4. data/lib/capybara.rb +50 -29
  5. data/lib/capybara/driver/base.rb +4 -0
  6. data/lib/capybara/driver/node.rb +4 -0
  7. data/lib/capybara/helpers.rb +17 -5
  8. data/lib/capybara/node/actions.rb +16 -11
  9. data/lib/capybara/node/base.rb +7 -7
  10. data/lib/capybara/node/document_matchers.rb +1 -1
  11. data/lib/capybara/node/element.rb +82 -7
  12. data/lib/capybara/node/finders.rb +62 -22
  13. data/lib/capybara/node/matchers.rb +3 -3
  14. data/lib/capybara/node/simple.rb +6 -1
  15. data/lib/capybara/queries/base_query.rb +1 -1
  16. data/lib/capybara/queries/current_path_query.rb +58 -0
  17. data/lib/capybara/queries/text_query.rb +2 -11
  18. data/lib/capybara/rack_test/browser.rb +7 -2
  19. data/lib/capybara/rack_test/driver.rb +4 -0
  20. data/lib/capybara/rack_test/form.rb +2 -1
  21. data/lib/capybara/rack_test/node.rb +1 -0
  22. data/lib/capybara/result.rb +2 -2
  23. data/lib/capybara/rspec.rb +1 -0
  24. data/lib/capybara/rspec/features.rb +1 -1
  25. data/lib/capybara/rspec/matchers.rb +42 -3
  26. data/lib/capybara/selector.rb +7 -2
  27. data/lib/capybara/selenium/driver.rb +26 -12
  28. data/lib/capybara/selenium/node.rb +42 -6
  29. data/lib/capybara/server.rb +1 -1
  30. data/lib/capybara/session.rb +78 -50
  31. data/lib/capybara/session/matchers.rb +69 -0
  32. data/lib/capybara/spec/public/test.js +8 -0
  33. data/lib/capybara/spec/session/all_spec.rb +5 -0
  34. data/lib/capybara/spec/session/assert_current_path.rb +59 -0
  35. data/lib/capybara/spec/session/assert_text.rb +1 -1
  36. data/lib/capybara/spec/session/attach_file_spec.rb +2 -2
  37. data/lib/capybara/spec/session/body_spec.rb +2 -0
  38. data/lib/capybara/spec/session/click_button_spec.rb +17 -8
  39. data/lib/capybara/spec/session/click_link_spec.rb +32 -1
  40. data/lib/capybara/spec/session/current_url_spec.rb +5 -0
  41. data/lib/capybara/spec/session/fill_in_spec.rb +1 -1
  42. data/lib/capybara/spec/session/find_field_spec.rb +17 -0
  43. data/lib/capybara/spec/session/find_spec.rb +14 -5
  44. data/lib/capybara/spec/session/first_spec.rb +24 -0
  45. data/lib/capybara/spec/session/has_current_path_spec.rb +68 -0
  46. data/lib/capybara/spec/session/has_link_spec.rb +3 -0
  47. data/lib/capybara/spec/session/has_text_spec.rb +7 -0
  48. data/lib/capybara/spec/session/node_spec.rb +45 -6
  49. data/lib/capybara/spec/session/reset_session_spec.rb +18 -1
  50. data/lib/capybara/spec/session/save_and_open_page_spec.rb +19 -0
  51. data/lib/capybara/spec/session/save_page_spec.rb +12 -3
  52. data/lib/capybara/spec/session/save_screenshot_spec.rb +23 -0
  53. data/lib/capybara/spec/session/select_spec.rb +12 -0
  54. data/lib/capybara/spec/session/title_spec.rb +2 -2
  55. data/lib/capybara/spec/session/window/become_closed_spec.rb +4 -4
  56. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +8 -0
  57. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +14 -8
  58. data/lib/capybara/spec/session/window/window_spec.rb +24 -4
  59. data/lib/capybara/spec/spec_helper.rb +3 -1
  60. data/lib/capybara/spec/test_app.rb +10 -1
  61. data/lib/capybara/spec/views/form.erb +7 -1
  62. data/lib/capybara/spec/views/path.erb +12 -0
  63. data/lib/capybara/spec/views/with_html.erb +2 -0
  64. data/lib/capybara/spec/views/with_js.erb +9 -1
  65. data/lib/capybara/spec/views/with_title.erb +4 -1
  66. data/lib/capybara/spec/views/with_windows.erb +2 -2
  67. data/lib/capybara/version.rb +1 -1
  68. data/spec/basic_node_spec.rb +1 -0
  69. data/spec/capybara_spec.rb +12 -3
  70. data/spec/dsl_spec.rb +18 -6
  71. data/spec/rack_test_spec.rb +6 -5
  72. data/spec/rspec/matchers_spec.rb +62 -16
  73. data/spec/rspec/views_spec.rb +7 -0
  74. data/spec/selenium_spec.rb +38 -3
  75. data/spec/selenium_spec_chrome.rb +3 -7
  76. metadata +13 -4
@@ -16,12 +16,11 @@ module Capybara
16
16
 
17
17
  ##
18
18
  #
19
- # Finds a link by id or text and clicks it. Also looks at image
19
+ # Finds a link by id, text or title and clicks it. Also looks at image
20
20
  # alt text inside the link.
21
21
  #
22
- # @param [String] locator Text or id of link
23
- # @param options
24
- # @option options [String] :href The value the href attribute must be
22
+ # @param [String] locator text, id, title or nested image's alt attribute
23
+ # @param options See {Capybara::Node::Finders#find_link}
25
24
  #
26
25
  def click_link(locator, options={})
27
26
  find(:link, locator, options).click
@@ -29,10 +28,13 @@ module Capybara
29
28
 
30
29
  ##
31
30
  #
32
- # Finds a button by id, text or value and clicks it.
33
- #
34
- # @param [String] locator Text, id or value of button
31
+ # Finds a button on the page and clicks it.
32
+ # This can be any \<input> element of type submit, reset, image, button or it can be a
33
+ # \<button> element. All buttons can be found by their id, value, or title. \<button> elements can also be found
34
+ # by their text content, and image \<input> elements by their alt attribute
35
35
  #
36
+ # @param [String] locator Which button to find
37
+ # @param options See {Capybara::Node::Finders#find_button}
36
38
  def click_button(locator, options={})
37
39
  find(:button, locator, options).click
38
40
  end
@@ -97,14 +99,17 @@ module Capybara
97
99
 
98
100
  ##
99
101
  #
100
- # Find a select box on the page and select a particular option from it. If the select
101
- # box is a multiple select, +select+ can be called multiple times to select more than
102
- # one option. The select box can be found via its name, id or label text.
102
+ # If `:from` option is present, `select` finds a select box on the page
103
+ # and selects a particular option from it.
104
+ # Otherwise it finds an option inside current scope and selects it.
105
+ # If the select box is a multiple select, +select+ can be called multiple times to select more than
106
+ # one option.
107
+ # The select box can be found via its name, id or label text. The option can be found by its text.
103
108
  #
104
109
  # page.select 'March', :from => 'Month'
105
110
  #
106
111
  # @param [String] value Which option to select
107
- # @param [Hash{:from => String}] options The id, name or label of the select box
112
+ # @option options [String] :from The id, name or label of the select box
108
113
  #
109
114
  def select(value, options={})
110
115
  if options.has_key?(:from)
@@ -61,10 +61,10 @@ module Capybara
61
61
  #
62
62
  # As long as any of these exceptions are thrown, the block is re-run,
63
63
  # until a certain amount of time passes. The amount of time defaults to
64
- # {Capybara.default_wait_time} and can be overridden through the `seconds`
64
+ # {Capybara.default_max_wait_time} and can be overridden through the `seconds`
65
65
  # argument. This time is compared with the system time to see how much
66
- # time has passed. If the return value of `Time.now` is stubbed out,
67
- # Capybara will raise `Capybara::FrozenInTime`.
66
+ # time has passed. On rubies/platforms which don't support access to a monotonic process clock
67
+ # if the return value of `Time.now` is stubbed out, Capybara will raise `Capybara::FrozenInTime`.
68
68
  #
69
69
  # @param [Integer] seconds Number of seconds to retry this block
70
70
  # @param options [Hash]
@@ -73,8 +73,8 @@ module Capybara
73
73
  # @return [Object] The result of the given block
74
74
  # @raise [Capybara::FrozenInTime] If the return value of `Time.now` appears stuck
75
75
  #
76
- def synchronize(seconds=Capybara.default_wait_time, options = {})
77
- start_time = Time.now
76
+ def synchronize(seconds=Capybara.default_max_wait_time, options = {})
77
+ start_time = Capybara::Helpers.monotonic_time
78
78
 
79
79
  if session.synchronized
80
80
  yield
@@ -86,9 +86,9 @@ module Capybara
86
86
  session.raise_server_error!
87
87
  raise e unless driver.wait?
88
88
  raise e unless catch_error?(e, options[:errors])
89
- raise e if (Time.now - start_time) >= seconds
89
+ raise e if (Capybara::Helpers.monotonic_time - start_time) >= seconds
90
90
  sleep(0.05)
91
- raise Capybara::FrozenInTime, "time appears to be frozen, Capybara does not work with libraries which freeze time, consider using time travelling instead" if Time.now == start_time
91
+ raise Capybara::FrozenInTime, "time appears to be frozen, Capybara does not work with libraries which freeze time, consider using time travelling instead" if Capybara::Helpers.monotonic_time == start_time
92
92
  reload if Capybara.automatic_reload
93
93
  retry
94
94
  ensure
@@ -9,7 +9,7 @@ module Capybara
9
9
  # @param string [String] The string that title should include
10
10
  # @overload $0(regexp, options = {})
11
11
  # @param regexp [Regexp] The regexp that title should match to
12
- # @option options [Numeric] :wait (Capybara.default_wait_time) Time that Capybara will wait for title to eq/match given string/regexp argument
12
+ # @option options [Numeric] :wait (Capybara.default_max_wait_time) Maximum time that Capybara will wait for title to eq/match given string/regexp argument
13
13
  # @raise [Capybara::ExpectationNotMet] if the assertion hasn't succeeded during wait time
14
14
  # @return [true]
15
15
  #
@@ -3,7 +3,7 @@ module Capybara
3
3
 
4
4
  ##
5
5
  #
6
- # A {Capybara::Element} represents a single element on the page. It is possible
6
+ # A {Capybara::Node::Element} represents a single element on the page. It is possible
7
7
  # to interact with the contents of this element the same as with a document:
8
8
  #
9
9
  # session = Capybara::Session.new(:rack_test, my_app)
@@ -11,7 +11,7 @@ module Capybara
11
11
  # bar = session.find('#bar') # from Capybara::Node::Finders
12
12
  # bar.select('Baz', :from => 'Quox') # from Capybara::Node::Actions
13
13
  #
14
- # {Capybara::Element} also has access to HTML attributes and other properties of the
14
+ # {Capybara::Node::Element} also has access to HTML attributes and other properties of the
15
15
  # element:
16
16
  #
17
17
  # bar.value
@@ -93,10 +93,10 @@ module Capybara
93
93
  #
94
94
  def set(value, options={})
95
95
  options ||= {}
96
-
96
+
97
97
  driver_supports_options = (base.method(:set).arity != 1)
98
98
 
99
- unless options.empty? || driver_supports_options
99
+ unless options.empty? || driver_supports_options
100
100
  warn "Options passed to Capybara::Node#set but the driver doesn't support them"
101
101
  end
102
102
 
@@ -114,6 +114,7 @@ module Capybara
114
114
  # Select this node if is an option element inside a select tag
115
115
  #
116
116
  def select_option
117
+ warn "Attempt to select disabled option: #{value || text}" if disabled?
117
118
  synchronize { base.select_option }
118
119
  end
119
120
 
@@ -149,6 +150,80 @@ module Capybara
149
150
  synchronize { base.double_click }
150
151
  end
151
152
 
153
+ ##
154
+ #
155
+ # Send Keystrokes to the Element
156
+ #
157
+ # @overload send_keys(keys, ...)
158
+ # @param [String, Symbol, Array<String,Symbol>] keys
159
+ #
160
+ # Examples:
161
+ #
162
+ # element.send_keys "foo" #=> value: 'foo'
163
+ # element.send_keys "tet", :left, "s" #=> value: 'test'
164
+ # element.send_keys [:control, 'a'], :space #=> value: ' ' - assuming ctrl-a selects all contents
165
+ #
166
+ # Symbols supported for keys
167
+ # :cancel
168
+ # :help
169
+ # :backspace
170
+ # :tab
171
+ # :clear
172
+ # :return
173
+ # :enter
174
+ # :shift
175
+ # :control
176
+ # :alt
177
+ # :pause
178
+ # :escape
179
+ # :space
180
+ # :page_up
181
+ # :page_down
182
+ # :end
183
+ # :home
184
+ # :left
185
+ # :up
186
+ # :right
187
+ # :down
188
+ # :insert
189
+ # :delete
190
+ # :semicolon
191
+ # :equals
192
+ # :numpad0
193
+ # :numpad1
194
+ # :numpad2
195
+ # :numpad3
196
+ # :numpad4
197
+ # :numpad5
198
+ # :numpad6
199
+ # :numpad7
200
+ # :numpad8
201
+ # :numpad9
202
+ # :multiply - numeric keypad *
203
+ # :add - numeric keypad +
204
+ # :separator - numeric keypad 'separator' key ??
205
+ # :subtract - numeric keypad -
206
+ # :decimal - numeric keypad .
207
+ # :divide - numeric keypad /
208
+ # :f1
209
+ # :f2
210
+ # :f3
211
+ # :f4
212
+ # :f5
213
+ # :f6
214
+ # :f7
215
+ # :f8
216
+ # :f9
217
+ # :f10
218
+ # :f11
219
+ # :f12
220
+ # :meta
221
+ # :command - alias of :meta
222
+ #
223
+ def send_keys(*args)
224
+ synchronize { base.send_keys(*args) }
225
+ end
226
+
152
227
  ##
153
228
  #
154
229
  # Hover on the Element
@@ -235,7 +310,7 @@ module Capybara
235
310
  # target = page.find('#bar')
236
311
  # source.drag_to(target)
237
312
  #
238
- # @param [Capybara::Element] node The element to drag to
313
+ # @param [Capybara::Node::Element] node The element to drag to
239
314
  #
240
315
  def drag_to(node)
241
316
  synchronize { base.drag_to(node.base) }
@@ -254,9 +329,9 @@ module Capybara
254
329
  end
255
330
 
256
331
  def inspect
257
- %(#<Capybara::Element tag="#{tag_name}" path="#{path}">)
332
+ %(#<Capybara::Node::Element tag="#{tag_name}" path="#{path}">)
258
333
  rescue NotSupportedByDriverError
259
- %(#<Capybara::Element tag="#{tag_name}">)
334
+ %(#<Capybara::Node::Element tag="#{tag_name}">)
260
335
  end
261
336
  end
262
337
  end
@@ -4,13 +4,15 @@ module Capybara
4
4
 
5
5
  ##
6
6
  #
7
- # Find an {Capybara::Element} based on the given arguments. +find+ will raise an error if the element
7
+ # Find an {Capybara::Node::Element} based on the given arguments. +find+ will raise an error if the element
8
8
  # is not found.
9
9
  #
10
- # If the driver is capable of executing JavaScript, +find+ will wait for a set amount of time
11
- # and continuously retry finding the element until either the element is found or the time
12
- # expires. The length of time +find+ will wait is controlled through {Capybara.default_wait_time}
13
- # and defaults to 2 seconds.
10
+ # @!macro waiting_behavior
11
+ # If the driver is capable of executing JavaScript, +$0+ will wait for a set amount of time
12
+ # and continuously retry finding the element until either the element is found or the time
13
+ # expires. The length of time +find+ will wait is controlled through {Capybara.default_max_wait_time}
14
+ # and defaults to 2 seconds.
15
+ # @option options [false, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear.
14
16
  #
15
17
  # +find+ takes the same options as +all+.
16
18
  #
@@ -19,10 +21,10 @@ module Capybara
19
21
  # page.find('li', :text => 'Quox').click_link('Delete')
20
22
  #
21
23
  # @param (see Capybara::Node::Finders#all)
24
+ #
22
25
  # @option options [Boolean] match The matching strategy to use.
23
- # @option options [false, Numeric] wait How long to wait for the element to appear.
24
26
  #
25
- # @return [Capybara::Element] The found element
27
+ # @return [Capybara::Node::Element] The found element
26
28
  # @raise [Capybara::ElementNotFound] If the element can't be found before time expires
27
29
  #
28
30
  def find(*args)
@@ -48,8 +50,17 @@ module Capybara
48
50
  #
49
51
  # Find a form field on the page. The field can be found by its name, id or label text.
50
52
  #
51
- # @param [String] locator Which field to find
52
- # @return [Capybara::Element] The found element
53
+ # @macro waiting_behavior
54
+ #
55
+ # @param [String] locator Which field to find
56
+ #
57
+ # @option options [Boolean] checked Match checked field?
58
+ # @option options [Boolean] unchecked Match unchecked field?
59
+ # @option options [Boolean] disabled (false) Match disabled field?
60
+ # @option options [Boolean] readonly Match readonly field?
61
+ # @option options [String] with Value of field to match on
62
+ # @option options [String] type Type of field to match on
63
+ # @return [Capybara::Node::Element] The found element
53
64
  #
54
65
  def find_field(locator, options={})
55
66
  find(:field, locator, options)
@@ -60,8 +71,11 @@ module Capybara
60
71
  #
61
72
  # Find a link on the page. The link can be found by its id or text.
62
73
  #
63
- # @param [String] locator Which link to find
64
- # @return [Capybara::Element] The found element
74
+ # @macro waiting_behavior
75
+ #
76
+ # @param [String] locator Which link to find
77
+ # @option options [String,Regexp] href Value to match against the links href
78
+ # @return [Capybara::Node::Element] The found element
65
79
  #
66
80
  def find_link(locator, options={})
67
81
  find(:link, locator, options)
@@ -69,10 +83,16 @@ module Capybara
69
83
 
70
84
  ##
71
85
  #
72
- # Find a button on the page. The button can be found by its id, name or value.
86
+ # Find a button on the page.
87
+ # This can be any \<input> element of type submit, reset, image, button or it can be a
88
+ # \<button> element. All buttons can be found by their id, value, or title. \<button> elements can also be found
89
+ # by their text content, and image \<input> elements by their alt attribute
90
+
91
+ # @macro waiting_behavior
73
92
  #
74
- # @param [String] locator Which button to find
75
- # @return [Capybara::Element] The found element
93
+ # @param [String] locator Which button to find
94
+ # @option options [Boolean] disabled (false) Match disabled button?
95
+ # @return [Capybara::Node::Element] The found element
76
96
  #
77
97
  def find_button(locator, options={})
78
98
  find(:button, locator, options)
@@ -82,8 +102,11 @@ module Capybara
82
102
  #
83
103
  # Find a element on the page, given its id.
84
104
  #
85
- # @param [String] id Which element to find
86
- # @return [Capybara::Element] The found element
105
+ # @macro waiting_behavior
106
+ #
107
+ # @param [String] id Which element to find
108
+ #
109
+ # @return [Capybara::Node::Element] The found element
87
110
  #
88
111
  def find_by_id(id, options={})
89
112
  find(:id, id, options)
@@ -117,8 +140,9 @@ module Capybara
117
140
  # page.all('#menu li', :visible => true)
118
141
  #
119
142
  # By default if no elements are found, an empty array is returned;
120
- # however, expectations can be set on the number of elements to be
121
- # found using:
143
+ # however, expectations can be set on the number of elements to be found which
144
+ # will trigger Capybara's waiting behavior for the expectations to match.The
145
+ # expectations can be set using
122
146
  #
123
147
  # page.assert_selector('p#foo', :count => 4)
124
148
  # page.assert_selector('p#foo', :maximum => 10)
@@ -132,13 +156,18 @@ module Capybara
132
156
  # @param [:css, :xpath] kind The type of selector
133
157
  # @param [String] locator The selector
134
158
  # @option options [String, Regexp] text Only find elements which contain this text or match this regexp
135
- # @option options [Boolean] visible Only find elements that are visible on the page. Setting this to false
136
- # finds invisible _and_ visible elements.
159
+ # @option options [Boolean, Symbol] visible Only find elements with the specified visibility:
160
+ # * true - only finds visible elements.
161
+ # * false - finds invisible _and_ visible elements.
162
+ # * :all - same as false; finds visible and invisible elements.
163
+ # * :hidden - only finds invisible elements.
164
+ # * :visible - same as true; only finds visible elements.
137
165
  # @option options [Integer] count Exact number of matches that are expected to be found
138
166
  # @option options [Integer] maximum Maximum number of matches that are expected to be found
139
167
  # @option options [Integer] minimum Minimum number of matches that are expected to be found
140
168
  # @option options [Range] between Number of matches found must be within the given range
141
169
  # @option options [Boolean] exact Control whether `is` expressions in the given XPath match exactly or partially
170
+ # @option options [Integer] wait (Capybara.default_max_wait_time) The time to wait for element count expectations to become true
142
171
  # @return [Capybara::Result] A collection of found elements
143
172
  #
144
173
  def all(*args)
@@ -149,20 +178,31 @@ module Capybara
149
178
  result
150
179
  end
151
180
  end
181
+ alias_method :find_all, :all
152
182
 
153
183
  ##
154
184
  #
155
185
  # Find the first element on the page matching the given selector
156
- # and options, or nil if no element matches.
186
+ # and options, or nil if no element matches. By default no waiting
187
+ # behavior occurs, however if {Capybara.wait_on_first_by_default} is set to true
188
+ # it will trigger Capybara's waiting behavior for a minimum of 1 matching element to be found and
189
+ # return the first. Waiting behavior can also be triggered by passing in any of the count
190
+ # expectation options.
157
191
  #
158
192
  # @overload first([kind], locator, options)
159
193
  # @param [:css, :xpath] kind The type of selector
160
194
  # @param [String] locator The selector
161
195
  # @param [Hash] options Additional options; see {#all}
162
- # @return [Capybara::Element] The found element or nil
196
+ # @return [Capybara::Node::Element] The found element or nil
163
197
  #
164
198
  def first(*args)
199
+ if Capybara.wait_on_first_by_default
200
+ options = if args.last.is_a?(Hash) then args.pop.dup else {} end
201
+ args.push({minimum: 1}.merge(options))
202
+ end
165
203
  all(*args).first
204
+ rescue Capybara::ExpectationNotMet
205
+ nil
166
206
  end
167
207
  end
168
208
  end
@@ -220,7 +220,7 @@ module Capybara
220
220
  #
221
221
  # @param [String] locator The text or id of a link to check for
222
222
  # @param options
223
- # @option options [String] :href The value the href attribute must be
223
+ # @option options [String, Regexp] :href The value the href attribute must be
224
224
  # @return [Boolean] Whether it exists
225
225
  #
226
226
  def has_link?(locator, options={})
@@ -437,14 +437,14 @@ module Capybara
437
437
  # @option options [Integer] :minimum (nil) Minimum number of times the text is expected to occur
438
438
  # @option options [Integer] :maximum (nil) Maximum number of times the text is expected to occur
439
439
  # @option options [Range] :between (nil) Range of times that is expected to contain number of times text occurs
440
- # @option options [Numeric] :wait (Capybara.default_wait_time) Time that Capybara will wait for text to eq/match given string/regexp argument
440
+ # @option options [Numeric] :wait (Capybara.default_max_wait_time) Maximum time that Capybara will wait for text to eq/match given string/regexp argument
441
441
  # @overload $0(text, options = {})
442
442
  # @param [String, Regexp] text The string/regexp to check for. If it's a string, text is expected to include it. If it's a regexp, text is expected to match it.
443
443
  # @option options [Integer] :count (nil) Number of times the text is expected to occur
444
444
  # @option options [Integer] :minimum (nil) Minimum number of times the text is expected to occur
445
445
  # @option options [Integer] :maximum (nil) Maximum number of times the text is expected to occur
446
446
  # @option options [Range] :between (nil) Range of times that is expected to contain number of times text occurs
447
- # @option options [Numeric] :wait (Capybara.default_wait_time) Time that Capybara will wait for text to eq/match given string/regexp argument
447
+ # @option options [Numeric] :wait (Capybara.default_max_wait_time) Maximum time that Capybara will wait for text to eq/match given string/regexp argument
448
448
  # @raise [Capybara::ExpectationNotMet] if the assertion hasn't succeeded during wait time
449
449
  # @return [true]
450
450
  #
@@ -146,7 +146,12 @@ module Capybara
146
146
  end
147
147
 
148
148
  def title
149
- native.xpath("//title").first.text
149
+ if native.respond_to? :title
150
+ native.title
151
+ else
152
+ #old versions of nokogiri don't have #title - remove in 3.0
153
+ native.xpath('/html/head/title | /html/title').first.text
154
+ end
150
155
  end
151
156
 
152
157
  def inspect
@@ -10,7 +10,7 @@ module Capybara
10
10
  if @options.has_key?(:wait)
11
11
  @options[:wait] || 0
12
12
  else
13
- Capybara.default_wait_time
13
+ Capybara.default_max_wait_time
14
14
  end
15
15
  end
16
16