I am attempting to write a Mechanize test script for a form that contains pairs of duplicate field names. E.g.,
<select id="birth_month" name="birthdate"> <option value=""> -- </option> <option value="01"> Jan </option> ... </select> <select id="birth_day" name="birthdate"> <option value="01"> 01 </option> ... </select>
There doesn't seem to be a straightforward approach to setting both fields at the same time.
$mech = Test::WWW::Mechanize->new(); ... $mech->submit_form( with_fields => { ..., 'birthdate' => ['01',0] }); # or $mech->set_fields({ ..., 'birthdate' => ['01',0] });
Both of these set only a single value.
$mech->field('birthdate', ['01'], 0); $mech->field('birthdate', ['17'], 1);
and the first setting is lost (overwritten by the second). I also tried HTTP::Recorder as a proxy to see what would be submitted, but it just uses the last approach (multiple calls to 'field' without apparent success). Yes, I could alter the form to avoid this, but there's a fair amount of work downstream if I do. I just want to send two values through the form under one CGI parameter, just as the real form does in the browser.

Jeff Boes <>< jeff.boes@gmail.com

In reply to Duplicate field names and Test::WWW::Mechanize by Mur

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.