I'm using WWW::Mechanize::Firefox and am trying to use the synchronize method like so:
$mech->get('http://example.com/wp-login.php');
$mech->submit_form( with_fields => {log => 'admin', pwd => 'password'});
$self->synchronize( 'DOMContentLoaded', sub {print Dumper($self->title()); });
exit;
The title of the newly loaded page prints but then the script just hangs. It never exits. What am I missing?
The subroutine that you pass to
synchronizeis meant to do something that kicks off an update to the browser page.synchronizecalls it and then waits for the event you have specified before it returnsClearly your
printstatement won't change the web page at all, so no events will fire and your code will be suspended indefinitelyI suggest you put the call to
submit_formin the subroutine you pass tosynchronize. That at least stands a chance of causingDOMContentLoadedto fireIt would look like this