Hi all, I need to auto submit a form which has javascript in it. The html is given below.
<form action="/goform/formHandlerConfigureDMPName" method="post" onsub +mit = "return validateDMPNameOnSubmit(this)"> <td width="5%"><img src="../invis.gif" alt="" width="50" heigh +t="30"/></td> <td width="45%">DMP Name:</td> <td width="50%"><input type="text" name="DMPName" value="Curre +nt Name" maxlength="129"/>&nbsp;&nbsp;<input type="submit" value="App +ly"/></td> </form>
The output of mech-dump utility is:
POST http://xxx.xxx.xxx.xxx/goform/formHandlerConfigureDMPName DMPName=Current Name (text) <NONAME>=Apply (submit)
But while trying to set the current form to the desired one using the method form_with_fields(), it returns an error "No elements found for form with fields [DMPName]".
my $input_name = 'DMPName'; my $web_url = 'http://xxx.xxx.xxx.xxx/DMP_config.asp'; my $mech = WWW::Mechanize::Firefox->new(); $mech->get($web_url, no_cache => 1); $current_form = $mech->form_with_fields($input_name); print "Present value of $input_name: " . $mech->value($input_name);
With the above code snippet it is possible to select and set the current form to different forms in the same web page.

Any help to figure out this issue is appreciated.


In reply to Not able to select the form with WWW::Mechanize::Firefox using form_with_fields() by ajose

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.