Mechanize SelectList Issue

Discussion in 'Ruby' started by jwcooper, Mar 20, 2007.

  1. jwcooper

    jwcooper Guest

    Hi,

    I have been pretty successful in using Mechanize for submitting forms
    of all types. The following select list has been giving me trouble to
    no ends. I am not able to get it to submit for any reason. It
    actually submits the form, but when I look at what I submitted, the
    value is always blank.

    Here is the select list:

    <select style="font-family: Arial, sans-serif; font-size: 11px;"
    name="Greetings" size="1">
    <option value="">Please Select
    <option>YO
    <option>HELLO
    <option>HOLA
    </select>

    One thing to note is that the <option>'s don't get closed (</
    option>). Would this cause issues with Mechanize? When I "pp" the
    page it seems list the three options with the correct text (although
    it looks like this 'YO\n\t\t\t\t\t'), and with 'null' values.

    Here is what I have tried to no avail:

    form.fields.name('Greetings').options[1].click
    form.fields.name('Greetings').options[1].select
    form.field('Greetings').options[1].select
    form.field('Greetings').options[1].click
    form.fields('Greetings').options[1].click

    I can successfully grab the values out of the options by using:

    myselectlist = form.fields.name('Greetings').options[1]
    puts myselectlist.text

    Any ideas on why I can't submit the form with the option I want to
    select? I can submit the form, but the 'select' never gets
    processed. No errors are thrown.

    Thank you for any help you can provide!
     
    jwcooper, Mar 20, 2007
    #1
    1. Advertising

  2. jwcooper

    jwcooper Guest

    On Mar 20, 3:13 pm, "jwcooper" <> wrote:
    > Hi,
    >
    > I have been pretty successful in using Mechanize for submitting forms
    > of all types. The following select list has been giving me trouble to
    > no ends. I am not able to get it to submit for any reason. It
    > actually submits the form, but when I look at what I submitted, the
    > value is always blank.
    >
    > Here is the select list:
    >
    > <select style="font-family: Arial, sans-serif; font-size: 11px;"
    > name="Greetings" size="1">
    > <option value="">Please Select
    > <option>YO
    > <option>HELLO
    > <option>HOLA
    > </select>
    >
    > One thing to note is that the <option>'s don't get closed (</
    > option>). Would this cause issues with Mechanize? When I "pp" the
    > page it seems list the three options with the correct text (although
    > it looks like this 'YO\n\t\t\t\t\t'), and with 'null' values.
    >
    > Here is what I have tried to no avail:
    >
    > form.fields.name('Greetings').options[1].click
    > form.fields.name('Greetings').options[1].select
    > form.field('Greetings').options[1].select
    > form.field('Greetings').options[1].click
    > form.fields('Greetings').options[1].click
    >
    > I can successfully grab the values out of the options by using:
    >
    > myselectlist = form.fields.name('Greetings').options[1]
    > puts myselectlist.text
    >
    > Any ideas on why I can't submit the form with the option I want to
    > select? I can submit the form, but the 'select' never gets
    > processed. No errors are thrown.
    >
    > Thank you for any help you can provide!


    I am still a bit out of luck on this one. Anyone have any ideas?

    I've also tried just setting the value of the select list to my
    desired value, and that didn't work either.

    Thank you!
     
    jwcooper, Mar 21, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gianni
    Replies:
    2
    Views:
    878
    Gianni
    Apr 19, 2004
  2. bruce
    Replies:
    0
    Views:
    1,395
    bruce
    Jul 10, 2006
  3. shapper

    Create SelectList

    shapper, Sep 7, 2008, in forum: ASP .Net
    Replies:
    5
    Views:
    748
    bruce barker
    Sep 8, 2008
  4. rodchar

    asp.net mvc SelectList help

    rodchar, Sep 30, 2009, in forum: ASP .Net
    Replies:
    4
    Views:
    1,855
    rodchar
    Sep 30, 2009
  5. Giel Raijmakers

    popup after selection from selectlist

    Giel Raijmakers, Jan 4, 2008, in forum: Ruby
    Replies:
    0
    Views:
    104
    Giel Raijmakers
    Jan 4, 2008
Loading...

Share This Page