Forum: RSpec Webrat - Fill in text field by id

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Steve M. (Guest)
on 2009-03-06 18:53
(Received via mailing list)
Is there a way to locate and 'fill in' a text field (or check a check
box,
select an option, etc.) by id?  It seems that the fill_in method takes
either the text of the label pointing to the field or the field name.
The
are cases when writing cucumber steps when using the HTML id of the
input
element would be easier, especially when a page has multiple forms with
the
same labels and input names.
Thanks,

Steve
James B. (Guest)
on 2009-03-06 19:03
Steve M. wrote:
> Is there a way to locate and 'fill in' a text field (or check a check
> box,
> select an option, etc.) by id?  It seems that the fill_in method takes
> either the text of the label pointing to the field or the field name.
> The
> are cases when writing cucumber steps when using the HTML id of the
> input
> element would be easier, especially when a page has multiple forms with
> the
> same labels and input names.
> Thanks,
>
> Steve


Yes, just provide the text of the id selector, do not add anything else.

So, for an id="test_this_id" on a button you can write in your
test/definition:

click_button("test-this_id")
James B. (Guest)
on 2009-03-06 19:04
James B. wrote:
S/B
>
> click_button("test_this_id")
Yi W. (Guest)
on 2009-03-06 19:17
(Received via mailing list)
It does take id. At least in the trunk webrat
Steve M. (Guest)
on 2009-03-06 22:31
(Received via mailing list)
Well I'm reading the 0.4.2 webrat rdoc for fill_in, at it says:
"field can be either the value of a name attribute (i.e. user[email]) or
the
text inside a <label>element that points at the <input> field."

Does it also try the id?

Steve
Stephen E. (Guest)
on 2009-03-06 22:50
(Received via mailing list)
On Fri, Mar 6, 2009 at 2:22 PM, Steve M. <removed_email_address@domain.invalid>
wrote:
> Well I'm reading the 0.4.2 webrat rdoc for fill_in, at it says:
> "field can be either the value of a name attribute (i.e. user[email]) or the
> text inside a <label>element that points at the <input> field."
> Does it also try the id?

Try it!  (Or read the code.  Or both.)



--
Have Fun,
   Steve E. (removed_email_address@domain.invalid)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
Yi W. (Guest)
on 2009-03-06 23:21
(Received via mailing list)
Could you just try it?
This topic is locked and can not be replied to.