capybara 2.1.0 → 2.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/History.md +48 -1
  5. data/README.md +22 -18
  6. data/lib/capybara.rb +28 -3
  7. data/lib/capybara/cucumber.rb +0 -2
  8. data/lib/capybara/driver/base.rb +9 -1
  9. data/lib/capybara/empty.html +4 -0
  10. data/lib/capybara/node/actions.rb +1 -1
  11. data/lib/capybara/node/finders.rb +3 -3
  12. data/lib/capybara/node/matchers.rb +22 -18
  13. data/lib/capybara/node/simple.rb +5 -3
  14. data/lib/capybara/query.rb +1 -0
  15. data/lib/capybara/rack_test/browser.rb +5 -4
  16. data/lib/capybara/rack_test/form.rb +5 -2
  17. data/lib/capybara/rack_test/node.rb +2 -1
  18. data/lib/capybara/result.rb +2 -1
  19. data/lib/capybara/rspec.rb +7 -0
  20. data/lib/capybara/rspec/features.rb +2 -0
  21. data/lib/capybara/rspec/matchers.rb +6 -6
  22. data/lib/capybara/selector.rb +3 -1
  23. data/lib/capybara/selenium/driver.rb +14 -2
  24. data/lib/capybara/selenium/node.rb +18 -5
  25. data/lib/capybara/server.rb +3 -7
  26. data/lib/capybara/session.rb +59 -17
  27. data/lib/capybara/spec/public/test.js +1 -1
  28. data/lib/capybara/spec/session/assert_selector.rb +18 -0
  29. data/lib/capybara/spec/session/attach_file_spec.rb +5 -0
  30. data/lib/capybara/spec/session/check_spec.rb +14 -0
  31. data/lib/capybara/spec/session/choose_spec.rb +14 -0
  32. data/lib/capybara/spec/session/click_button_spec.rb +20 -1
  33. data/lib/capybara/spec/session/fill_in_spec.rb +18 -2
  34. data/lib/capybara/spec/session/go_back_spec.rb +10 -0
  35. data/lib/capybara/spec/session/go_forward_spec.rb +12 -0
  36. data/lib/capybara/spec/session/has_button_spec.rb +24 -0
  37. data/lib/capybara/spec/session/has_field_spec.rb +48 -0
  38. data/lib/capybara/spec/session/has_text_spec.rb +18 -0
  39. data/lib/capybara/spec/session/node_spec.rb +36 -1
  40. data/lib/capybara/spec/session/reset_session_spec.rb +17 -2
  41. data/lib/capybara/spec/session/save_page_spec.rb +10 -4
  42. data/lib/capybara/spec/session/visit_spec.rb +16 -0
  43. data/lib/capybara/spec/session/within_frame_spec.rb +7 -0
  44. data/lib/capybara/spec/session/within_window_spec.rb +7 -0
  45. data/lib/capybara/spec/test_app.rb +1 -0
  46. data/lib/capybara/spec/views/form.erb +40 -0
  47. data/lib/capybara/spec/views/with_html.erb +5 -0
  48. data/lib/capybara/spec/views/with_js.erb +8 -0
  49. data/lib/capybara/version.rb +1 -1
  50. data/spec/capybara_spec.rb +1 -1
  51. data/spec/result_spec.rb +14 -0
  52. data/spec/rspec/features_spec.rb +15 -0
  53. data/spec/rspec/matchers_spec.rb +24 -1
  54. data/spec/selenium_spec.rb +8 -1
  55. data/spec/server_spec.rb +13 -5
  56. metadata +78 -98
  57. metadata.gz.sig +0 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 74e082700fc9740e3c65c86598a724d842beb06c
4
+ data.tar.gz: 3263eafad157eebba120e04e016224a0a7b0ff1d
5
+ SHA512:
6
+ metadata.gz: 8fdb43337d8cf32573c4828c1e53051f4a2bf967d650931c424a47f8a50f7aa58821227d6726291a52a7bb6ee626f394ea3b91a1eaddab14b322ecf5710e23fd
7
+ data.tar.gz: b986b258932c0ff9d4b52e36415babe8e658200fe14f62ec8be9fec1344dbfbae184d9df6ea804c04238821e689b9ddac399dc5a916f217e323a30b9667a6dd3
Binary file
data.tar.gz.sig CHANGED
Binary file
data/History.md CHANGED
@@ -1,6 +1,53 @@
1
+ # Version 2.2.0
2
+
3
+ Release date: 2013-11-14
4
+
5
+ ### Added
6
+
7
+ * Add `go_back` and `go_forward` methods. [Vasiliy Ermolovich]
8
+ * Support RSpec 3 [Thomas Holmes]
9
+ * `has_button?`, `has_checked_field?` and `has_unchecked_field?` accept
10
+ options, like other matchers. [Carol Nichols]
11
+ * The `assert_selector` and `has_text?` methods now support the `:wait` option
12
+ [Vasiliy Ermolovich]
13
+ * RackTest's visible? method now checks for the HTML5 `hidden` attribute.
14
+ * Results from `#all` now delegate the `sample` method. [Phil Lee]
15
+ * The `set` method now works for contenteditable attributes under Selenium.
16
+ [Jon Rowe]
17
+ * radio buttons and check boxes can be filtered by option value, useful when
18
+ selecting by name [Jonas Nicklas]
19
+ * feature blocks can be nested within other feature blocks in RSpec tests
20
+ [Travis Gaff]
21
+
22
+ ### Fixed
23
+
24
+ * Fixed race conditions causing stale element errors when filtering by text.
25
+ [Jonas Nicklas]
26
+ * Resetting the page is now synchronous and navigates to an empty HTML file,
27
+ instead of `about:blank`, fixing hanging issues in JRuby. [Jonas Nicklas]
28
+ * Fixed cookies not being set when path is blank under RackTest [Thomas Walpole]
29
+ * Clearing fields now correctly causes change events [Jonas Nicklas]
30
+ * Navigating to an absolut URI without trailing slash now works as expected
31
+ under RackTest [Jonas Nicklas]
32
+ * Checkboxes without assigned value default to `on` under RackTest [Nigel Sheridan-Smith]
33
+ * Clicks on buttons with no form associated with them are ignored in RackTest
34
+ instead of raising an obscure exception. [Thomas Walpole]
35
+ * execute_script is now a session method [Andrey Botalov]
36
+ * Nesting `within_window` and `within_frame` inside `within` resets the scope
37
+ so that they behave like a user would expect [Thomas Walpole]
38
+ * Improve handling of newlines in textareas [Thomas Walpole]
39
+ * `Capybara::Result` delegates its inspect method, so as not to confuse users
40
+ [Sam Rawlins]
41
+ * save_page always returns a full path, fixes problems with Launchy [Jonas Nicklas]
42
+ * Selenium driver's `quit` method does nothing when browser hasn't been loaded
43
+ [randoum]
44
+ * Capybara's WEBRick server now propertly respects the server_host option
45
+ [Dmitry Vorotilin]
46
+ * gemspec now includes license information [Jonas Nicklas]
47
+
1
48
  # Version 2.1.0
2
49
 
3
- Release date: Unreleased
50
+ Release date: 2013-04-09
4
51
 
5
52
  ### Changed
6
53
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/jnicklas/capybara.png)](http://travis-ci.org/jnicklas/capybara)
4
4
  [![Dependency Status](https://gemnasium.com/jnicklas/capybara.png)](https://gemnasium.com/jnicklas/capybara)
5
- [![Code Quality](https://codeclimate.com/badge.png)](https://codeclimate.com/github/jnicklas/capybara)
5
+ [![Code Climate](https://codeclimate.com/github/jnicklas/capybara.png)](https://codeclimate.com/github/jnicklas/capybara)
6
6
 
7
7
  Capybara helps you test web applications by simulating how a real user would
8
8
  interact with your app. It is agnostic about the driver running your tests and
@@ -96,7 +96,7 @@ Capybara with `:type => :feature`.
96
96
  You can now write your specs like so:
97
97
 
98
98
  ```ruby
99
- describe "the signup process", :type => :feature do
99
+ describe "the signin process", :type => :feature do
100
100
  before :each do
101
101
  User.make(:email => 'user@example.com', :password => 'caplin')
102
102
  end
@@ -108,7 +108,7 @@ describe "the signup process", :type => :feature do
108
108
  fill_in 'Password', :with => 'password'
109
109
  end
110
110
  click_link 'Sign in'
111
- page.should have_content 'Success'
111
+ expect(page).to have_content 'Success'
112
112
  end
113
113
  end
114
114
  ```
@@ -127,7 +127,7 @@ end
127
127
  Finally, Capybara also comes with a built in DSL for creating descriptive acceptance tests:
128
128
 
129
129
  ```ruby
130
- feature "Signing up" do
130
+ feature "Signing in" do
131
131
  background do
132
132
  User.make(:email => 'user@example.com', :password => 'caplin')
133
133
  end
@@ -139,7 +139,7 @@ feature "Signing up" do
139
139
  fill_in 'Password', :with => 'caplin'
140
140
  end
141
141
  click_link 'Sign in'
142
- page.should have_content 'Success'
142
+ expect(page).to have_content 'Success'
143
143
  end
144
144
 
145
145
  given(:other_user) { User.make(:email => 'other@example.com', :password => 'rous') }
@@ -151,7 +151,7 @@ feature "Signing up" do
151
151
  fill_in 'Password', :with => other_user.password
152
152
  end
153
153
  click_link 'Sign in'
154
- page.should have_content 'Invalid email or password'
154
+ expect(page).to have_content 'Invalid email or password'
155
155
  end
156
156
  end
157
157
  ```
@@ -162,7 +162,7 @@ end
162
162
 
163
163
  ## Using Capybara with Test::Unit
164
164
 
165
- * If you are using Rails, add the following code in your `test_helper.rb`
165
+ * If you are using Rails, add the following code in your `test_helper.rb`
166
166
  file to make Capybara available in all test cases deriving from
167
167
  `ActionDispatch::IntegrationTest`:
168
168
 
@@ -209,7 +209,7 @@ end
209
209
  Set up your base class as with Test::Unit. (On Rails, the right base class
210
210
  could be something other than ActionDispatch::IntegrationTest.)
211
211
 
212
- The capybara_minitest_spec gem ([Github](https://github.com/ordinaryzelig/capybara_minitest_spec),
212
+ The capybara_minitest_spec gem ([GitHub](https://github.com/ordinaryzelig/capybara_minitest_spec),
213
213
  [rubygems.org](https://rubygems.org/gems/capybara_minitest_spec)) provides MiniTest::Spec
214
214
  expectations for Capybara. For example:
215
215
 
@@ -271,7 +271,7 @@ RackTest can be configured with a set of headers like this:
271
271
 
272
272
  ```ruby
273
273
  Capybara.register_driver :rack_test do |app|
274
- Capybara::RackTest::Driver.new(app, :browser => :chrome)
274
+ Capybara::RackTest::Driver.new(app, :headers => { 'HTTP_USER_AGENT' => 'Capybara' })
275
275
  end
276
276
  ```
277
277
 
@@ -281,10 +281,12 @@ See the section on adding and configuring drivers.
281
281
 
282
282
  At the moment, Capybara supports [Selenium 2.0
283
283
  (Webdriver)](http://seleniumhq.org/docs/01_introducing_selenium.html#selenium-2-aka-selenium-webdriver),
284
- *not* Selenium RC. Provided Firefox is installed, everything is set up for you,
285
- and you should be able to start using Selenium right away.
284
+ *not* Selenium RC. In order to use Selenium, you'll need to install the
285
+ `selenium-webdriver` gem, and add it to your Gemfile if you're using bundler.
286
+ Provided Firefox is installed, everything is set up for you, and you should be
287
+ able to start using Selenium right away.
286
288
 
287
- **Note**: drivers which run the server in a different thread may not work share the
289
+ **Note**: drivers which run the server in a different thread may not share the
288
290
  same transaction as your tests, causing data not to be shared between your test
289
291
  and test server, see "Transactions and database setup" below.
290
292
 
@@ -325,7 +327,7 @@ Capybara heavily uses XPath, which doesn't support case insensitivity.
325
327
  ### Navigating
326
328
 
327
329
  You can use the
328
- [#visit](http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Session#visit-instance_method)
330
+ <tt>[visit](http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Session#visit-instance_method)</tt>
329
331
  method to navigate to other pages:
330
332
 
331
333
  ```ruby
@@ -450,8 +452,6 @@ within(:xpath, "//li[@id='employee']") do
450
452
  end
451
453
  ```
452
454
 
453
- **Note**: `within` will scope the actions to the _first_ (not _any_) element that matches the selector.
454
-
455
455
  There are special methods for restricting the scope to a specific fieldset,
456
456
  identified by either an id or the text of the fieldset's legend tag, and to a
457
457
  specific table, identified by either id or text of the table's caption tag.
@@ -794,7 +794,7 @@ end
794
794
 
795
795
  Capybara makes it convenient to switch between different drivers. It also exposes
796
796
  an API to tweak those drivers with whatever settings you want, or to add your own
797
- drivers. This is how to switch the selenium driver to use chrome:
797
+ drivers. This is how to override the selenium driver configuration to use chrome:
798
798
 
799
799
  ```ruby
800
800
  Capybara.register_driver :selenium do |app|
@@ -802,8 +802,7 @@ Capybara.register_driver :selenium do |app|
802
802
  end
803
803
  ```
804
804
 
805
- However, it's also possible to give this a different name, so tests can switch
806
- between using different browsers effortlessly:
805
+ However, it's also possible to give this configuration a different name.
807
806
 
808
807
  ```ruby
809
808
  Capybara.register_driver :selenium_chrome do |app|
@@ -811,6 +810,11 @@ Capybara.register_driver :selenium_chrome do |app|
811
810
  end
812
811
  ```
813
812
 
813
+ Then tests can switch between using different browsers effortlessly:
814
+ ```ruby
815
+ Capybara.current_driver = :selenium_chrome
816
+ ```
817
+
814
818
  Whatever is returned from the block should conform to the API described by
815
819
  Capybara::Driver::Base, it does not however have to inherit from this class.
816
820
  Gems can use this API to add their own drivers to Capybara.
@@ -14,12 +14,14 @@ module Capybara
14
14
  class NotSupportedByDriverError < CapybaraError; end
15
15
  class InfiniteRedirectError < CapybaraError; end
16
16
 
17
+ EMPTY_HTML_FILE_PATH = File.expand_path('./capybara/empty.html', File.dirname(__FILE__))
18
+
17
19
  class << self
18
20
  attr_accessor :asset_host, :app_host, :run_server, :default_host, :always_include_port
19
- attr_accessor :server_host, :server_port, :exact, :match, :exact_options, :visible_text_only
21
+ attr_accessor :server_port, :exact, :match, :exact_options, :visible_text_only
20
22
  attr_accessor :default_selector, :default_wait_time, :ignore_hidden_elements
21
23
  attr_accessor :save_and_open_page_path, :automatic_reload, :raise_server_errors
22
- attr_writer :default_driver, :current_driver, :javascript_driver, :session_name
24
+ attr_writer :default_driver, :current_driver, :javascript_driver, :session_name, :server_host
23
25
  attr_accessor :app
24
26
 
25
27
  ##
@@ -166,7 +168,7 @@ module Capybara
166
168
  #
167
169
  def run_default_server(app, port)
168
170
  require 'rack/handler/webrick'
169
- Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
171
+ Rack::Handler::WEBrick.run(app, :Host => server_host, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
170
172
  end
171
173
 
172
174
  ##
@@ -214,6 +216,14 @@ module Capybara
214
216
  @current_driver = previous_driver
215
217
  end
216
218
 
219
+ ##
220
+ #
221
+ # @return [String] The IP address bound by default server
222
+ #
223
+ def server_host
224
+ @server_host || '127.0.0.1'
225
+ end
226
+
217
227
  ##
218
228
  #
219
229
  # Yield a block using a specific wait time
@@ -267,6 +277,21 @@ module Capybara
267
277
  self.session_name = :default
268
278
  end
269
279
 
280
+ ##
281
+ #
282
+ # Parse raw html into a document using Nokogiri, and adjust textarea contents as defined by the spec.
283
+ #
284
+ # @param [String] html The raw html
285
+ # @return [Nokogiri::HTML::Document] HTML document
286
+ #
287
+ def HTML(html)
288
+ Nokogiri::HTML(html).tap do |document|
289
+ document.xpath('//textarea').each do |textarea|
290
+ textarea.content=textarea.content.sub(/\A\n/,'')
291
+ end
292
+ end
293
+ end
294
+
270
295
  def included(base)
271
296
  base.send(:include, Capybara::DSL)
272
297
  warn "`include Capybara` is deprecated. Please use `include Capybara::DSL` instead."
@@ -1,6 +1,4 @@
1
1
  require 'capybara'
2
-
3
- require 'capybara/dsl'
4
2
  require 'capybara/rspec/matchers'
5
3
 
6
4
  World(Capybara::DSL)
@@ -10,7 +10,7 @@ class Capybara::Driver::Base
10
10
  def find_xpath(query)
11
11
  raise NotImplementedError
12
12
  end
13
-
13
+
14
14
  def find_css(query)
15
15
  raise NotImplementedError
16
16
  end
@@ -19,6 +19,14 @@ class Capybara::Driver::Base
19
19
  raise NotImplementedError
20
20
  end
21
21
 
22
+ def go_back
23
+ raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#go_back'
24
+ end
25
+
26
+ def go_forward
27
+ raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#go_forward'
28
+ end
29
+
22
30
  def execute_script(script)
23
31
  raise Capybara::NotSupportedByDriverError, 'Capybara::Driver::Base#execute_script'
24
32
  end
@@ -0,0 +1,4 @@
1
+ <!doctype>
2
+ <html>
3
+ <!-- an empty HTML document, used for resetting the page content -->
4
+ </html>
@@ -19,7 +19,7 @@ module Capybara
19
19
  # Finds a link by id or text and clicks it. Also looks at image
20
20
  # alt text inside the link.
21
21
  #
22
- # @param [String] locator Text, id or text of link
22
+ # @param [String] locator Text or id of link
23
23
  # @param options
24
24
  # @option options [String] :href The value the href attribute must be
25
25
  #
@@ -147,16 +147,16 @@ module Capybara
147
147
  private
148
148
 
149
149
  def resolve_query(query, exact=nil)
150
- elements = synchronize do
151
- if query.selector.format==:css
150
+ synchronize do
151
+ elements = if query.selector.format==:css
152
152
  base.find_css(query.css)
153
153
  else
154
154
  base.find_xpath(query.xpath(exact))
155
155
  end.map do |node|
156
156
  Capybara::Node::Element.new(session, node, self, query)
157
157
  end
158
+ Capybara::Result.new(elements, query)
158
159
  end
159
- Capybara::Result.new(elements, query)
160
160
  end
161
161
  end
162
162
  end
@@ -85,7 +85,8 @@ module Capybara
85
85
  # @raise [Capybara::ExpectationNotMet] If the selector does not exist
86
86
  #
87
87
  def assert_selector(*args)
88
- synchronize do
88
+ query = Capybara::Query.new(*args)
89
+ synchronize(query.wait) do
89
90
  result = all(*args)
90
91
  result.matches_count? or raise Capybara::ExpectationNotMet, result.failure_message
91
92
  end
@@ -101,7 +102,8 @@ module Capybara
101
102
  # @raise [Capybara::ExpectationNotMet] If the selector exists
102
103
  #
103
104
  def assert_no_selector(*args)
104
- synchronize do
105
+ query = Capybara::Query.new(*args)
106
+ synchronize(query.wait) do
105
107
  result = all(*args)
106
108
  result.matches_count? and raise Capybara::ExpectationNotMet, result.negative_failure_message
107
109
  end
@@ -215,7 +217,8 @@ module Capybara
215
217
  # @return [Boolean] Whether it exists
216
218
  #
217
219
  def has_text?(*args)
218
- synchronize do
220
+ query = Capybara::Query.new(*args)
221
+ synchronize(query.wait) do
219
222
  raise ExpectationNotMet unless text_found?(*args)
220
223
  end
221
224
  return true
@@ -233,7 +236,8 @@ module Capybara
233
236
  # @return [Boolean] Whether it doesn't exist
234
237
  #
235
238
  def has_no_text?(*args)
236
- synchronize do
239
+ query = Capybara::Query.new(*args)
240
+ synchronize(query.wait) do
237
241
  raise ExpectationNotMet if text_found?(*args)
238
242
  end
239
243
  return true
@@ -276,8 +280,8 @@ module Capybara
276
280
  # @param [String] locator The text, value or id of a button to check for
277
281
  # @return [Boolean] Whether it exists
278
282
  #
279
- def has_button?(locator)
280
- has_selector?(:button, locator)
283
+ def has_button?(locator, options={})
284
+ has_selector?(:button, locator, options)
281
285
  end
282
286
 
283
287
  ##
@@ -288,8 +292,8 @@ module Capybara
288
292
  # @param [String] locator The text, value or id of a button to check for
289
293
  # @return [Boolean] Whether it doesn't exist
290
294
  #
291
- def has_no_button?(locator)
292
- has_no_selector?(:button, locator)
295
+ def has_no_button?(locator, options={})
296
+ has_no_selector?(:button, locator, options)
293
297
  end
294
298
 
295
299
  ##
@@ -341,8 +345,8 @@ module Capybara
341
345
  # @param [String] locator The label, name or id of a checked field
342
346
  # @return [Boolean] Whether it exists
343
347
  #
344
- def has_checked_field?(locator)
345
- has_selector?(:field, locator, :checked => true)
348
+ def has_checked_field?(locator, options={})
349
+ has_selector?(:field, locator, options.merge(:checked => true))
346
350
  end
347
351
 
348
352
  ##
@@ -352,10 +356,10 @@ module Capybara
352
356
  # checked.
353
357
  #
354
358
  # @param [String] locator The label, name or id of a checked field
355
- # @return [Boolean] Whether it doesn't exists
359
+ # @return [Boolean] Whether it doesn't exist
356
360
  #
357
- def has_no_checked_field?(locator)
358
- has_no_selector?(:field, locator, :checked => true)
361
+ def has_no_checked_field?(locator, options={})
362
+ has_no_selector?(:field, locator, options.merge(:checked => true))
359
363
  end
360
364
 
361
365
  ##
@@ -367,8 +371,8 @@ module Capybara
367
371
  # @param [String] locator The label, name or id of an unchecked field
368
372
  # @return [Boolean] Whether it exists
369
373
  #
370
- def has_unchecked_field?(locator)
371
- has_selector?(:field, locator, :unchecked => true)
374
+ def has_unchecked_field?(locator, options={})
375
+ has_selector?(:field, locator, options.merge(:unchecked => true))
372
376
  end
373
377
 
374
378
  ##
@@ -378,10 +382,10 @@ module Capybara
378
382
  # unchecked.
379
383
  #
380
384
  # @param [String] locator The label, name or id of an unchecked field
381
- # @return [Boolean] Whether it doesn't exists
385
+ # @return [Boolean] Whether it doesn't exist
382
386
  #
383
- def has_no_unchecked_field?(locator)
384
- has_no_selector?(:field, locator, :unchecked => true)
387
+ def has_no_unchecked_field?(locator, options={})
388
+ has_no_selector?(:field, locator, options.merge(:unchecked => true))
385
389
  end
386
390
 
387
391
  ##
@@ -18,7 +18,7 @@ module Capybara
18
18
  attr_reader :native
19
19
 
20
20
  def initialize(native)
21
- native = Nokogiri::HTML(native) if native.is_a?(String)
21
+ native = Capybara::HTML(native) if native.is_a?(String)
22
22
  @native = native
23
23
  end
24
24
 
@@ -74,7 +74,7 @@ module Capybara
74
74
  #
75
75
  def value
76
76
  if tag_name == 'textarea'
77
- native.content.sub(/\A\n/, '')
77
+ native.content
78
78
  elsif tag_name == 'select'
79
79
  if native['multiple'] == 'multiple'
80
80
  native.xpath(".//option[@selected='selected']").map { |option| option[:value] || option.content }
@@ -82,6 +82,8 @@ module Capybara
82
82
  option = native.xpath(".//option[@selected='selected']").first || native.xpath(".//option").first
83
83
  option[:value] || option.content if option
84
84
  end
85
+ elsif tag_name == 'input' && %w(radio checkbox).include?(native[:type])
86
+ native[:value] || 'on'
85
87
  else
86
88
  native[:value]
87
89
  end
@@ -95,7 +97,7 @@ module Capybara
95
97
  # @return [Boolean] Whether the element is visible
96
98
  #
97
99
  def visible?
98
- native.xpath("./ancestor-or-self::*[contains(@style, 'display:none') or contains(@style, 'display: none') or name()='script' or name()='head']").size == 0
100
+ native.xpath("./ancestor-or-self::*[contains(@style, 'display:none') or contains(@style, 'display: none') or @hidden or name()='script' or name()='head']").size == 0
99
101
  end
100
102
 
101
103
  ##