parent
1cf7bff09f
commit
c2320a4f95
|
@ -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") }
|
||||
|
|
|
@ -37,6 +37,10 @@ class Webcat::Session
|
|||
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
|
||||
end
|
||||
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue