Hidden fields

Culerity has problems with this.
This commit is contained in:
Jonas Nicklas 2009-11-11 21:48:33 +01:00
parent 1cf7bff09f
commit c2320a4f95
3 changed files with 17 additions and 3 deletions

View File

@ -13,7 +13,7 @@ class Webcat::Driver::RackTest
end
def set(value)
if tag_name == 'input' and %w(text password).include?(type)
if tag_name == 'input' and %w(text password hidden).include?(type)
node['value'] = value.to_s
elsif tag_name == 'input' and type == 'radio'
session.html.xpath("//input[@name='#{self[:name]}']").each { |node| node.remove_attribute("checked") }

View File

@ -36,6 +36,10 @@ class Webcat::Session
def choose(locator)
find_field(locator, :radio).set(true)
end
def set_hidden_field(locator, options={})
find_field(locator, :hidden_field).set(options[:to])
end
def body
driver.body
@ -59,7 +63,8 @@ private
:text_field => proc { |id| "//input[@type='text'][@id='#{id}']" },
:text_area => proc { |id| "//textarea[@id='#{id}']" },
:password_field => proc { |id| "//input[@type='password'][@id='#{id}']" },
:radio => proc { |id| "//input[@type='radio'][@id='#{id}']" }
:radio => proc { |id| "//input[@type='radio'][@id='#{id}']" },
:hidden_field => proc { |id| "//input[@type='hidden'][@id='#{id}']" }
}
def find_field_by_id(locator, *kinds)

View File

@ -193,7 +193,16 @@ shared_examples_for "session" do
end
describe "#set_hidden_field" do
before do
@session.visit('/form')
end
it "should set a hidden field by id" do
pending "Culerity doesn't like hidden fields for some reason" if @session.mode == :culerity
@session.set_hidden_field("form_token", :to => 'test567')
@session.click_button('awesome')
YAML.load(@session.body)['token'].should == 'test567'
end
end
describe "#check" do