I've got sort of a weird situation on my hands here. I'm trying to use WWW::Mechanize to log into a page where the username/password fields are not initially present on the page (they appear via JavaScript once I click a certain radio button). Doing
my $mech = WWW::Mechanize->new(); $mech->get('http://www.forex.com/login.html'); $mech->field('txtLogin', 'myuserid');
gets me the error "No such field 'txtLogin' at /usr/share/perl5/WWW/Mechanize.pm line 1033". Meanwhile, I see from WWW::Mechanize::FAQ that there's zero support for JavaScript within Mechanize.

That said, is there a way to force Mechanize to pass parameter/value pairs to a form when no such parameters exist in the downloaded form? Alternately, is there any other workaround that might be applicable here? The page in the code snippet above is the real deal, so feel free to look at it for other fixes.

Thanks,
Alex Kirk

In reply to WWW::Mechanize for nonexistent fields? by schnarff

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.