hesco has asked for the wisdom of the Perl Monks concerning the following question:

Hey all!

In this line of html:

<input type="submit" value="Submit" onclick="return ValidateForm()" st +yle="FONT-SIZE: 19px; FONT-FAMILY: Arial">
what is it that WWW::Mechanize wants to click, when it tells me: "No clickable input with name Submit"? What am I missing here?

-- Hugh

if( $lal && $lol ) { $life++; }

Replies are listed 'Best First'.
Re: What does WWW::Mechanize consider Clickable input?
by jasonk (Parson) on Jan 14, 2007 at 22:27 UTC

    click() takes the name of the button as an argument, in your example the name is 'submit', and the value is 'Submit' (one is capitalized, the other is not.) If you want to click a button by value, you can use the click_button() method...

    $mech->click_button( value => 'Submit' );

    We're not surrounded, we're in a target-rich environment!

      Actually, in his example there was no name. The type was 'submit', though.

      There was also no Perl code in his example.

Re: What does WWW::Mechanize consider Clickable input?
by petdance (Parson) on Jan 15, 2007 at 04:40 UTC
    You don't have to specify a button to submit a form. You can simply $mech->submit( ... blah blah blah ... ) without specifying a button.

    xoxo,
    Andy

      You need a form first (buttons outside of form tags won't work)
      use WWW::Mechanize; $ua=WWW::Mechanize->new; $ua->get('http://cpan.org');#no forms, contrast with search.cpan.org warn $ua->forms; warn $ua->submit; __END__ Warning: something's wrong at - line 6. Can't call method "make_request" on an undefined value at C:/Perl/site +/lib/WWW/Mechanize.pm line 1641.
Re: What does WWW::Mechanize consider Clickable input?
by stonecolddevin (Parson) on Jan 14, 2007 at 22:17 UTC

    I've got no experience with www::mech, but I know it doesn't support javascript.

    meh.

      Although this is true, if the application is well built it shouldn't matter, you should still be able to submit the form and have the validation done server side, any client-side validation done in javascript should be repeated on the server, since you can't trust the client to validate it's own input.


      We're not surrounded, we're in a target-rich environment!

        agreed jasonk, and attribute this to my lack of experience with the module, but I was just assuming (and we all know what assuming leads to) that the javascript was the perpetrator. maybe there's something before the button that's causing some undesired performance?

        meh.
Re: What does WWW::Mechanize consider Clickable input?
by kyle (Abbot) on Jan 14, 2007 at 22:34 UTC

    As dhoss notes, WWW::Mechanize won't handle JavaScript, and that may be important here, but I wonder if it might be that there's no form selected for it to click in. If you could show us your code, that might help.