On Sun, Jul 12, 2009 at 12:20, Ferlander
Davids<ferlanderdavids at gmail.com> wrote:> I''ve looked a little more carefully now. It looks like
it''s just <select
> name>, with the options below. Is there a way to interface with this
kind of
> element?
You were right that the ''menu'' is done with a <form>
tag.
Basically your code should work like this (I haven''t tested it):
- find the form - form = page.form(''form_id'') - check
what''s the
<form> ID or page.form_with(:name => ''f'')
- find the <select> - field = form.field_with(:name =>
''term_in'')
- tick the option you want to go to - field.options[n].select
- submit the form - form.submit
Please take a look at the docs:
http://mechanize.rubyforge.org/mechanize/EXAMPLES_rdoc.html
http://mechanize.rubyforge.org/mechanize/GUIDE_rdoc.html
Greetings,
Wojciech Piekutowski
> Thanks for your reply!
> Elliot
>
> <TR>
>
> <TD CLASS="delabel" scope="row" >Select a Term:
</TD>
>
> <TD CLASS="dedefault">
>
> <LABEL for=term_id><SPAN
class=fieldlabeltextinvisible>Term</SPAN></LABEL>
>
> <SELECT NAME="term_in" SIZE="1"
ID="term_id">
>
> <OPTION VALUE="201020">Fall 2009
>
> <OPTION VALUE="201010">Summer 2009
>
> </SELECT>
>
> <TD COLSPAN="11" CLASS="de"> </TD>
>
> </TR>
>
> </TABLE>
>
> <INPUT TYPE="submit" VALUE="Submit">
>
> </FORM>
>
> On Sun, Jul 12, 2009 at 2:51 AM, Wojciech Piekutowski
> <wojciech at piekutowski.net> wrote:
>>
>> On Sun, Jul 12, 2009 at 01:33, Ferlander Davids
>> <ferlanderdavids at gmail.com> wrote:
>> > I''m having trouble with a drop down menu. I
can''t find much mentioned in
>> > online references about drop down menus.
>> > I''ve tried a bunch of different things, right now
it''s
>> > form = page.form("term_in").first
>> >
>> > but that''s returning?nil.
>>
>> You need to find out what are the elements that render the menu. The
>> best approach is to look at the source code of the web page in
>> question and search for the menu part. I don''t think that your
menu is
>> stored in <form>, more probable are some <ul> or
<div> tags. Firebug
>> is often useful for this kind of tasks.
>>
>> Greetings,
>> Wojciech Piekutowski
>> _______________________________________________
>> Mechanize-users mailing list
>> Mechanize-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/mechanize-users
>
> _______________________________________________
> Mechanize-users mailing list
> Mechanize-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mechanize-users
>