in reply to Re^2: How to use synchronize method with WWW::Mechanize::Firefox?
in thread How to use synchronize method with WWW::Mechanize::Firefox?

Also tried $self->synchronize( 'DOMContentLoaded', sub { $self->click( {selector => '#wp-submit'} ); } );

Same results.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re^4: How to use synchronize method with WWW::Mechanize::Firefox?
by Corion (Patriarch) on Mar 27, 2016 at 14:07 UTC

    Do you really need to use ->synchronize? This method is mostly useful if you want to do things that do not end up loading a new page.

      I'm not wedded to synchronize. I just want to find a more reliable way than sleep(2) and a less ridiculous way than sleep(30) to wait around for the page to load after a login attempt.

      Ultimately, I'm trying to figure out if the login was successful. WordPress just offers up a 200 success code whether login is successful or not so I need to look at the contents of the page to determine if the login worked.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks

        Maybe looking at the actual HTTP traffic shows you whether the thing detemining the login happens later, maybe through Javascript.

        I did not find a convenient way to list all events as they happen during page load. Maybe you're looking at the wrong Javascript event. In my experiments, I found DOMContentLoaded to be quite reliable, but maybe in your case load is more reliable.