mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
value of checbkox/radio defaults to "on" when not specified
This commit is contained in:
parent
33a699be13
commit
483f261c3c
3 changed files with 16 additions and 1 deletions
|
@ -82,6 +82,8 @@ module Capybara
|
|||
option = native.xpath(".//option[@selected='selected']").first || native.xpath(".//option").first
|
||||
option[:value] || option.content if option
|
||||
end
|
||||
elsif tag_name == 'input' && %w(radio checkbox).include?(native[:type])
|
||||
native[:value] || 'on'
|
||||
else
|
||||
native[:value]
|
||||
end
|
||||
|
|
|
@ -28,7 +28,10 @@ class Capybara::RackTest::Form < Capybara::RackTest::Node
|
|||
case field.name
|
||||
when 'input'
|
||||
if %w(radio checkbox).include? field['type']
|
||||
merge_param!(params, field['name'].to_s, field['value'].to_s) if field['checked']
|
||||
if field['checked']
|
||||
node=Capybara::RackTest::Node.new(self.driver, field)
|
||||
merge_param!(params, field['name'].to_s, node.value.to_s)
|
||||
end
|
||||
elsif %w(submit image).include? field['type']
|
||||
# TO DO identify the click button here (in document order, rather
|
||||
# than leaving until the end of the params)
|
||||
|
|
|
@ -67,6 +67,16 @@ Capybara::SpecHelper.spec "node" do
|
|||
@session.find('//textarea[1]').set("some <em>html</em> here")
|
||||
@session.find('//textarea[1]').value.should == "some <em>html</em> here"
|
||||
end
|
||||
|
||||
it "defaults to 'on' for checkbox" do
|
||||
@session.visit('/form')
|
||||
@session.find('//input[@id="valueless_checkbox"]').value.should == 'on'
|
||||
end
|
||||
|
||||
it "defaults to 'on' for radio buttons" do
|
||||
@session.visit('/form')
|
||||
@session.find('//input[@id="valueless_radio"]').value.should == 'on'
|
||||
end
|
||||
end
|
||||
|
||||
describe "#set" do
|
||||
|
|
Loading…
Reference in a new issue