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

Am I missing something; It seems
WWW::Mechanize can click() on a...
<INPUT TYPE=submit VALUE="Validate it!">
WWW::Mechanize can not click on a...
<BUTTON NAME=mybut VALUE=enter>Enter</BUTTON>
Is there a work around?

Replies are listed 'Best First'.
Re: WWW::Mechanize click()
by monarch (Priest) on May 30, 2005 at 01:58 UTC
    Yes, you're missing something.

    What happens when you click on an input of type submit? The form is submitted.

    What happens when you click on a button? I don't know.. depends on the button.. but nothing leads me to think it would have a default behaviour of submitting the form..

    Dig deeper into your HTML source. Is the button later bound to an action with javascript? Remember, WWW::Mechanize can't work out what javascript code does, so you're going to have to assist it. If the javascript submits the form, then perhaps you should call $mechanize->submit().

      Monarch is right.

      The thing you might consider if you really need to check JavaScript in your page, is have a look at httpunit.

      "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.
Re: WWW::Mechanize click()
by mda2 (Hermit) on May 30, 2005 at 02:25 UTC
    Iīm deprecated arround html :(!!!

    I supose itīs a mistake... when I see, the correct use is "<input type=button>", itīs true on HTML 3 (1997!!). But HTML 4 use this syntax... I need to return to school or to W3Schools! ;)

    This question isnīt a WWW:Mechanize problem... Itīs a occurs because HTML::Form design, when used package IgnoreInput to do button actions!! Can you submit a bug at cpan with more samples!!!
    I currently donīt need to use WWW::Mechanize, and donīt has samples to make a good question to autor!)

    On time... HTML::Form is a package from libwww-perl.
    To post but you need to use RT at CPAN with good data for autorīs work...

    For solve your problems before wait eval and possible correct on HTML::Form try it:

    my $mech = WWW::Mechanize->new( autocheck => 1 ); #-- Redefine package to do button tasks (using same of submit) $HTML::Form::type2class{button} = "SubmitInput"; $mech->get( "...your url..." ); $mech->click('button_name'); print $mech->content;
    Update: I supose your button input has the same action with submit, but other name... Monarchīs node has more simple and solve your problem!

    --
    Marco Antonio
    Rio-PM