1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Uncheck checkboxes

This commit is contained in:
Jonas Nicklas 2009-11-11 22:38:55 +01:00
parent 91caa40326
commit d21ce44ef5
3 changed files with 28 additions and 2 deletions

View file

@ -19,7 +19,11 @@ class Webcat::Driver::RackTest
session.html.xpath("//input[@name='#{self[:name]}']").each { |node| node.remove_attribute("checked") }
node['checked'] = 'checked'
elsif tag_name == 'input' and type == 'checkbox'
node['checked'] = 'checked'
if value
node['checked'] = 'checked'
else
node.remove_attribute('checked')
end
elsif tag_name == "textarea"
node.content = value.to_s
end

View file

@ -44,6 +44,10 @@ class Webcat::Session
def check(locator)
find_field(locator, :checkbox).set(true)
end
def uncheck(locator)
find_field(locator, :checkbox).set(false)
end
def body
driver.body

View file

@ -224,7 +224,25 @@ shared_examples_for "session" do
end
describe "#uncheck" do
before do
@session.visit('/form')
end
it "should uncheck a checkbox by id" do
pending "Culerity doesn't seem to uncheck this" if @session.mode == :culerity
@session.uncheck("form_pets_hamster")
@session.click_button('awesome')
YAML.load(@session.body)['pets'].should include('dog')
YAML.load(@session.body)['pets'].should_not include('hamster')
end
it "should uncheck a checkbox by label" do
pending "Culerity doesn't seem to uncheck this" if @session.mode == :culerity
@session.uncheck("Hamster")
@session.click_button('awesome')
YAML.load(@session.body)['pets'].should include('dog')
YAML.load(@session.body)['pets'].should_not include('hamster')
end
end
describe "#select" do