Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails/ spec fill_in using placeholder

Tags:

rspec

In my rspec test, how do I fill_in a text field using Placeholder. I cannot use id and name as they are auto generated for the nested form.

<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">

Thanks

like image 861
anu Avatar asked Jul 12 '12 18:07

anu


2 Answers

There is also another way:

fill_in :placeholder => "Fill in some text", :with => "Text"
like image 61
x3qt Avatar answered Nov 22 '22 09:11

x3qt


Placeholder support will be in the next version of Capybara. For now, try:

find("input[placeholder='First Name']").set "value"
like image 32
Tanzeeb Khalili Avatar answered Nov 22 '22 07:11

Tanzeeb Khalili