#297 new
Catherine Powell

field_labeled fails on fields with explicit IDs

Reported by Catherine Powell | October 3rd, 2009 @ 11:47 PM

Using field_labeled(field).value etc... does not seem to find the field if the field I'm looking for has an id on the label.

I have a form with a field containing an id, like so:

  <p>
    <%= label_tag :username, :id => "username" %><br />
    <%= text_field_tag :username %>
  </p>

My step looks like this:

Then /^the "([^&quot;]*)" field should be empty$/ do |field|
  field_labeled(field).value.should be_nil
end

And I call it in my feature like so:

  Scenario: Login page loads

When I go to the login page
Then the &quot;Username&quot; field should be empty</code>



I get the following output:

Scenario: Login page loads
   When I go to the login page
   Then the "Username" field should be empty
   Could not find field labeled &quot;Username&quot; (Webrat::NotFoundError)
   (eval):2:in field_labeled'</code>
</pre>


Sample project (from which I took the code samples above) is attached. Run "login.feature" to see the failure. For reference, I've also included an "email" field, which is identical to the "username" field except that it does not have an ID. That bit works just fine (comment out "Then the "Username"..." to see it.

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Attachments

Pages