class Capybara::RackTest::Form
def add_input_param(field, params)
def add_input_param(field, params) if %w[radio checkbox].include? field['type'] if field['checked'] node = Capybara::RackTest::Node.new(driver, field) merge_param!(params, field['name'].to_s, node.value.to_s) end elsif %w[submit image].include? field['type'] # TODO: identify the click button here (in document order, rather # than leaving until the end of the params) elsif field['type'] == 'file' if multipart? file = if (value = field['value']).to_s.empty? NilUploadedFile.new else mime_info = MiniMime.lookup_by_filename(value) Rack::Test::UploadedFile.new(value, (mime_info && mime_info.content_type).to_s) end merge_param!(params, field['name'].to_s, file) else merge_param!(params, field['name'].to_s, File.basename(field['value'].to_s)) end else merge_param!(params, field['name'].to_s, field['value'].to_s) end end