Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 5340
Status: resolved
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors: andy [...] petdance.com
michael [...] schuerig.de
Cc: moregan [...] flr.follett.com
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.72
Fixed in: (no value)



Subject: Don't die on non-existent buttons
CC: moregan [...] flr.follett.com
if the button given to $agent->click( "_whatever" ) doesn't exist, should it really be die()ing ? Can't call method "click" on an undefined value at /usr/local/lib/perl5/site_perl/5.8.0/WWW/Mechanize.pm line 618.
This dying is done by HTML::Form. We'll need to eval{} the call and handle appropriately.
Subject: Click: fail gracefully
It would be nice if click would fail gracefully if the target button does not exist. Even better, it could behave according to the setting of autocheck. That way, instead of while (...) { my $next = $mech->{form}->find_input( "btnNext", "image" ); last unless $next; $mech->request( $next->click($mech->{form}) ); do_something( $mech->content() ); } one could write something like while (...) { $mech->click( "btnNext" ); last unless $mech->success(); do_something( $mech->content() ); } Thanks for this wonderful module! Michael
On Mon Nov 24 18:32:22 2003, andy@petdance.com wrote: Show quoted text
> if the button given to $agent->click( "_whatever" ) doesn't exist, > should it really be die()ing ? > > Can't call method "click" on an undefined value at > /usr/local/lib/perl5/site_perl/5.8.0/WWW/Mechanize.pm line 618.
Yes. Damian Conway suggested it was a best practice, and I agree: Throw exceptions instead of returning special values or setting flags. The autocheck/onwarn/onerror system present now is a sufficient flexible way to handle errors. I recommend considering this report "resolved". Mark