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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090306/6b4db7f4/attachment-0001.html>
It does take id. At least in the trunk webrat On Fri, Mar 6, 2009 at 10:23 AM, Steve Molitor <stevemolitor at gmail.com>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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090306/8b158fab/attachment.html>
Steve Molitor 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, > > SteveYes, 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") -- Posted via http://www.ruby-forum.com/.
James Byrne wrote: S/B> > click_button("test_this_id")-- Posted via http://www.ruby-forum.com/.
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 On Fri, Mar 6, 2009 at 11:03 AM, James Byrne <lists at ruby-forum.com> wrote:> Steve Molitor 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") > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090306/cc5319b3/attachment.html>
On Fri, Mar 6, 2009 at 2:22 PM, Steve Molitor <stevemolitor at gmail.com> 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 Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org
Could you just try it? On Fri, Mar 6, 2009 at 1:22 PM, Steve Molitor <stevemolitor at gmail.com>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? > > Steve > > On Fri, Mar 6, 2009 at 11:03 AM, James Byrne <lists at ruby-forum.com> wrote: > >> Steve Molitor 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") >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090306/04f99e50/attachment-0001.html>