我已经发现,当我想设置值的文本字段,文本区域或密码字段,我可以用ID,名称或标签作为something
在fill_in something, :with => some_value
。 然而,当我尝试值设置为这样的方法未能<input type="hidden">
字段(我想这样做,因为这些通常填充我分别测试客户端脚本)。 我怎么能设置成隐藏字段与水豚? 可能吗?
HTML:
<input id='offer_latitude' name='offer[latitude]' type='hidden'>
<input id='offer_longitude' name='offer[longitude]' type='hidden'>
规格:
describe "posting new offer" do
it "should add new offer" do
visit '/offer/new'
fill_in 'offer[latitude]', :with => '11.11'
fill_in 'offer[longitude]', :with => '12.12'
click_on 'add'
end
end
得到:
1) posting new offer should add new offer
Failure/Error: fill_in 'offer[latitude]', :with => '11.11'
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or label 'offer[latitude]' found