in reply to Re: mechanize bug - is there a workaround?
in thread mechanize bug - is there a workaround?

~$ perl -MWWW::Mechanize -e 'print "$WWW::Mechanize::VERSION\n"' 1.34 ~$ perl -version This is perl, v5.8.8 built for i486-linux-gnu-thread-multi
How do I tell my version of libwww-perl?

I used $mech->current_form->dump and I can see __VIEWSTATE, which is a non empty hidden field. But, I do not see __EVENTTARGET or __EVENTARGUMENT which are empty hidden fields.

I wonder what I am doing different from you.

tia, rouble

Replies are listed 'Best First'.
Re^3: mechanize bug - is there a workaround?
by almut (Canon) on Mar 14, 2008 at 22:15 UTC
    How do I tell my version of libwww-perl?

    Check the version of the module LWP

    $ perl -MLWP -e 'print "$LWP::VERSION\n"' 5.805

    and, just to be sure, also check HTML::Form (part of the bundle), as I suspect the problem could have originated in that module (Update: this doesn't make much sense, though — as the revision control timestamp of the respective file dates back to 2005/12/07 :).  Mine shows 1.0.54.

    I wonder what I am doing different from you.

    No idea :)  Here's what I did:

    use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $url = "file:///.../test.html"; # the mentioned form $mech->get($url); $mech->current_form->dump(); $mech->set_fields( '__EVENTTARGET' => 'mynewvalue' ); $mech->current_form->dump();

    which gives:

    $ ./674272.pl POST .../Browse.aspx?MyToken=632797078501515540 [aspnetForm] __EVENTTARGET= (hidden readonly) __EVENTARGUMENT= (hidden readonly) __VIEWSTATE=/wEPDwUJ (hidden readonly) POST .../Browse.aspx?MyToken=632797078501515540 [aspnetForm] __EVENTTARGET=mynewvalue (hidden readonly) __EVENTARGUMENT= (hidden readonly) __VIEWSTATE=/wEPDwUJ (hidden readonly)
      almut,

      I tried what you did, and I got the same result. You were right this defect has been fixed.

      After some investigation, I realized that the web server was sending different html depending on the user agent. Without setting a user agent the html did not include __EVENTTARGET and __EVENTARGUMENT. So I set my user agent to windows, as follows:
      $mech->agent_alias("Windows IE 6");
      This fixed the problem. Thanks for setting me on the right track!

      tia, rouble
        Hi can you share the complete code to workaround dopostback .NET method ? visuss at gmail Thanks