mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Uncheck checkboxes
This commit is contained in:
parent
91caa40326
commit
d21ce44ef5
3 changed files with 28 additions and 2 deletions
|
@ -19,7 +19,11 @@ class Webcat::Driver::RackTest
|
||||||
session.html.xpath("//input[@name='#{self[:name]}']").each { |node| node.remove_attribute("checked") }
|
session.html.xpath("//input[@name='#{self[:name]}']").each { |node| node.remove_attribute("checked") }
|
||||||
node['checked'] = 'checked'
|
node['checked'] = 'checked'
|
||||||
elsif tag_name == 'input' and type == 'checkbox'
|
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"
|
elsif tag_name == "textarea"
|
||||||
node.content = value.to_s
|
node.content = value.to_s
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,6 +44,10 @@ class Webcat::Session
|
||||||
def check(locator)
|
def check(locator)
|
||||||
find_field(locator, :checkbox).set(true)
|
find_field(locator, :checkbox).set(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def uncheck(locator)
|
||||||
|
find_field(locator, :checkbox).set(false)
|
||||||
|
end
|
||||||
|
|
||||||
def body
|
def body
|
||||||
driver.body
|
driver.body
|
||||||
|
|
|
@ -224,7 +224,25 @@ shared_examples_for "session" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#uncheck" do
|
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
|
end
|
||||||
|
|
||||||
describe "#select" do
|
describe "#select" do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue