in reply to Re^2: (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
You still don't show any Perl code, so I can't comment on how you call your Javascript and how it fails for you.
Personally, I check Javascript validation functions without actually submitting the form:
# Set up values to be tested ... $mech->field( $name => $value ); ... my ($value, $type) = $mech->eval_in_page('validateIpSettings()'); is($value, 'some expected value');
As your Javascript already is structured nicely, this conveniently eliminates the need for overriding window.alert. If you still want to override window.alert, you can do so by passing in the appropriate hash in the $env parameter to ->eval_in_page():
# create myalert as Javascript function my $myalert = $mech->declare(<<JS); function (msg) {}; JS my ($value, $type) = $mech->eval_in_page('validateIpSettings()', { + alert => $myalert });
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: (OT) How to override the javascript alert when submitting a form using WWW::Mechanize::Firefox
by jbernest (Novice) on May 03, 2013 at 08:41 UTC | |
by Corion (Patriarch) on May 03, 2013 at 08:45 UTC |