Rspec 使用占位符填充轨道/等级库

Rspec 使用占位符填充轨道/等级库,rspec,Rspec,在我的rspec测试中,如何使用占位符在文本字段中填充_。我不能使用id和name,因为它们是为嵌套表单自动生成的 <input class="input-medium inline" id="user_kids_attributes_new_1342116887461_first_name" name="user[kids_attributes][new_1342116887461][first_name]" placeholder="First Name" size="30" type

在我的rspec测试中,如何使用占位符在文本字段中填充_。我不能使用id和name,因为它们是为嵌套表单自动生成的

<input class="input-medium inline" id="user_kids_attributes_new_1342116887461_first_name" name="user[kids_attributes][new_1342116887461][first_name]" placeholder="First Name" size="30" type="text">


谢谢

占位符支持将出现在下一版本的Capybara中。现在,请尝试:

find("input[placeholder='First Name']").set "value"

还有另一种方法:

fill_in :placeholder => "Fill in some text", :with => "Text"

“卡号”
作为占位符

这应该有效,除非您试图在iframe中填充输入

在这种情况下:


至少从版本Capybara 2.3(可能更早)开始,这个

填充查找占位符文本。
Capybara 2.5
,您不应该指定
占位符
键,而应该像使用
填充“占位符名称”一样使用:“text”
fill_in('Card number', with: "#{arg1} #{arg2} #{arg3} #{arg4}")