Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^5: WWW::Mechanize click_button() not working in AIX

by onelesd (Pilgrim)
on Jul 10, 2012 at 21:45 UTC ( #980956=note: print w/replies, xml ) Need Help??


in reply to Re^4: WWW::Mechanize click_button() not working in AIX
in thread WWW::Mechanize click_button() not working in AIX

LWP::UserAgent which WWW::Mechanize inherits from takes care of SSL for you.

Have you tried $mech->find_all_submits( ... criteria ... ) and debugging that to make sure the button is recognized?

Replies are listed 'Best First'.
Re^6: WWW::Mechanize click_button() not working in AIX
by onelesd (Pilgrim) on Jul 10, 2012 at 23:07 UTC

    WWW::Mechanize is a subclass of LWP::UserAgent, so this should work:

    $mech->add_handler("request_send", sub { shift->dump; return }); $mech->add_handler("response_done", sub { shift->dump; return });

    After that, do you see the request after you click_button()?

      Ok, so the add_handler call showed a bunch of log messages. Below is the excerpt of the log

      GET https://www.myreports.com/tax_report.php?dc_range=Y&dc_date1=7%2F9 +%2F2012&dc_date2=7%2F9%2F2012 Accept-Encoding: gzip Referer: https://www.myreports.com/admin/ User-Agent: WWW-Mechanize/1.72 Cookie: PHPSESSID=df9f4mmljub54dfi0vvdm2lh12 Cookie2: $Version="1" (no content) HTTP/1.1 200 OK Cache-Control: post-check=0, pre-check=0 Connection: close Date: Wed, 11 Jul 2012 00:00:30 GMT Pragma: no-cache Server: Apache Vary: Accept-Encoding,User-Agent Content-Encoding: gzip Content-Length: 555 Content-Type: text/html; charset=iso-8859-1 Expires: Thu, 19 Nov 1981 08:52:00 GMT Client-Date: Wed, 11 Jul 2012 00:00:31 GMT Client-Peer: xx.xx.xx.xx:xxx Client-Response-Num: 1 Client-SSL-Cert-Issuer: /C=GB/ST=Greater Manchester/L=Salford/O=COMODO + CA Limited/CN=COMODO High-Assurance Secure Server CA Client-SSL-Cert-Subject: /C=US/postalCode=75238/ST=Texas/L=Dallas/stre +et=10300 Sanden Dr Suite 100/O=SpeedFC/OU=PlatinumSSL Wildcard/CN=*.m +yreports.com Client-SSL-Cipher: DHE-RSA-AES256-SHA Client-SSL-Warning: Peer certificate not verified

      The only warning I can see is the last line, looks like the SSL certificate cannot be verified. Not sure if this is causing the issue. In my Win machine, the program works even after the Warning.

        The warning is due to LWP::UserAgent not verifying the certificate. You can make it verify if you want (look at ssl_opts()), but that doesn't seem to be your problem.

        This debug excerpt doesn't look like the part we are interested in. Move the add_handler() calls to just before you call click_button(). You just want to verify whether or not the form is being submitted, in which case you'll see the request and then hopefully a response. If you don't see a request then you know for sure click_button() isn't working, but I can't tell you why it wouldn't be.

        If you can't get click_button() to go you could work around it- build the request like you would if you were just using LWP::UserAgent. Not ideal but sometimes you gotta just get things working.

Re^6: WWW::Mechanize click_button() not working in AIX
by perl_monster (Novice) on Jul 10, 2012 at 22:02 UTC

    I have used the below which is somewhat similar to what you mentioned

    my $inputobject=$mech->current_form()->find_input( undef,'submit' ); print $inputobject->value . "\n"; $mech->click_button(input => $inputobject); print $mech->status() . "\n";

    The $inputobject shows the correct button element as in the HTML source and the second print returns a status of 200 which apparently stands for OK. All of this still doesn't work, can't even see any errors anywhere. I attempted including LWP::Debug qw(+); in the code, but its not returning me any logging info either

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://980956]
help
Chatterbox?
and monks are getting baked in the sun...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-07-23 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (459 votes). Check out past polls.

    Notices?