in reply to Re^4: (OT) How to override the javascript alert when submitting a form using WWW::Mechanize::Firefox
in thread (OT) How to override the javascript alert when submitting a form using WWW::Mechanize::Firefox
There is no convenient way to detect window.alert() from WWW::Mechanize::Firefox. You can assign a dummy function to window.alert to override it. This will prevent alert boxes popping up until the next page load:
my $window= $mech->repl->expr('window'); $window->{alert}= sub {}; ...
Alternatively, you can put the override into Javascript directly:
$mech->eval_in_page(<<'JS'); window.alert= function() {}; JS
|
|---|