Executing JavaScript function using MozRepl and Perl (WWW::Mechanize::Firefox)

303 views Asked by At

I am using the following Perl snippet to execute a JavaScript function using MozRepl. However, I get the error message "MozRepl::RemoteObject: TypeError: myFunction is not a function at test.pl line 16." What am I doing wrong?

use v5.10;
use WWW::Mechanize::Firefox;
use strict;
use warnings;

my $mech = WWW::Mechanize::Firefox->new();
$mech->update_html(<<HTML);
<script type="text/javascript">
function myFunction() {
    alert("Hello World!");
}
</script>
HTML

sleep 2;
$mech->eval_in_page( 'myFunction();' );
0

There are 0 answers