libwww-perl / WWW-Mechanize

Handy web browsing in a Perl object
https://metacpan.org/pod/WWW::Mechanize
Other
68 stars 53 forks source link

click_button doesn't check for errors #155

Open spazm opened 7 years ago

spazm commented 7 years ago

i4z9k7...@sneakemail.com reported on Aug 18, 2009

What steps will reproduce the problem?

$ perl -MWWW::Mechanize -e '
  my $mech = WWW::Mechanize->new();
  $mech->get("http://cpan.org");          # site without form
  $mech->click_button(value => "does not exist");
'
Can't call method "find_input" on an undefined value at
/usr/share/perl5/WWW/Mechanize.pm line 1716.

$ perl -MWWW::Mechanize -e '
  my $mech = WWW::Mechanize->new();
  $mech->get("http://perldoc.perl.org");          # site with form
  $mech->click_button(value => "does not exist");
'
Can't call method "header" on an undefined value at
/usr/share/perl5/WWW/Mechanize.pm line 2381.

$ perl -MWWW::Mechanize -e '
  my $mech = WWW::Mechanize->new();
  $mech->get("http://cpan.org");          # site without form
  $mech->click_button(name => "does not exist");
'
Can't call method "click" on an undefined value at
/usr/share/perl5/WWW/Mechanize.pm line 1705.

$ perl -MWWW::Mechanize -e '
  my $mech = WWW::Mechanize->new();
  $mech->get("http://cpan.org");          # site without form
  $mech->click_button(number => 1);
'
Can't call method "find_input" on an undefined value at
/usr/share/perl5/WWW/Mechanize.pm line 1708.

and so on ... that sent me on a merry chase after a typo in a button
identifier.

What is the expected output? What do you see instead?

Something akin to the error message produced by 
$ perl -MWWW::Mechanize -e '
  my $mech = WWW::Mechanize->new();
  $mech->get("http://cpan.org/no-such-url");
'
Error GETing http://cpan.org/no-such-url: Not Found at -e line 3

I see the "can't call method 'foo' on an undefined value ..." errors instead.

What version of the product are you using? On what operating system?

$ grep 'our $VERSION' /usr/share/perl5/WWW/Mechanize.pm
our $VERSION = '1.58';

Debian Linux (amd64) sid, Debian-built perl executable 5.10.0

Details

Imported from Google Code issue 120 via archive

Comments

jsarvesh...@gmail.com commented on Mar 26, 2011 :

try using click() instead of click_button...

petda...@gmail.com commented on Apr 24, 2011 :

(No comment was entered for this change.)