Webrat - Fill in text field by id


#1

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


#2

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”)


#3

James B. wrote:
S/B

click_button(“test_this_id”)


#4

It does take id. At least in the trunk webrat


#5

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 element that points at the field.”

Does it also try the id?

Steve


#6

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 element that points at the 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


#7

Could you just try it?