lib/capybara/node/actions.rb in capybara-0.4.1.2 vs lib/capybara/node/actions.rb in capybara-1.0.0.beta1

- old
+ new

@@ -102,11 +102,11 @@ # box is a multiple select, +select+ can be called multiple times to select more than # one option. The select box can be found via its name, id or label text. # # page.select 'March', :from => 'Month' # - # @param [String] locator Which check box to uncheck + # @param [String] value Which option to select # @param [Hash{:from => String}] The id, name or label of the select box # def select(value, options={}) if options.has_key?(:from) no_select_msg = "cannot select option, no select box with id, name, or label '#{options[:from]}' found" @@ -119,17 +119,18 @@ end end ## # - # Find a select box on the page and select a particular option from it. If the select - # box is a multiple select, +select+ can be called multiple times to select more than + # Find a select box on the page and unselect a particular option from it. If the select + # box is a multiple select, +unselect+ can be called multiple times to unselect more than # one option. The select box can be found via its name, id or label text. # - # page.uncheck('German') + # page.unselect 'March', :from => 'Month' # - # @param [String] locator Which check box to uncheck + # @param [String] value Which option to unselect + # @param [Hash{:from => String}] The id, name or label of the select box # def unselect(value, options={}) if options.has_key?(:from) no_select_msg = "cannot unselect option, no select box with id, name, or label '#{options[:from]}' found" no_option_msg = "cannot unselect option, no option with text '#{value}' in select box '#{options[:from]}'" @@ -150,9 +151,10 @@ # # @param [String] locator Which field to attach the file to # @param [String] path The path of the file that will be attached # def attach_file(locator, path) + raise Capybara::FileNotFound, "cannot attach file, #{path} does not exist" unless File.exist?(path.to_s) msg = "cannot attach file, no file field with id, name, or label '#{locator}' found" find(:xpath, XPath::HTML.file_field(locator), :message => msg).set(path) end end end