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

So where does your callback perform an action, like clicking?

  • Comment on Re^2: How to use synchronize method with WWW::Mechanize::Firefox?

Replies are listed 'Best First'.
Re^3: How to use synchronize method with WWW::Mechanize::Firefox?
by nysus (Parson) on Mar 27, 2016 at 10:38 UTC

    OK, I reread your previous post. It has to click on a button? I will try that.

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

Re^3: How to use synchronize method with WWW::Mechanize::Firefox?
by nysus (Parson) on Mar 27, 2016 at 11:25 UTC

    Tried:

    $self->synchronize( 'DOMContentLoaded', sub { $self->click_button( nam +e => 'wp-submit' ); } );

    I still get same results. The next page loads but then browser hangs.

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

Re^3: How to use synchronize method with WWW::Mechanize::Firefox?
by nysus (Parson) on Mar 27, 2016 at 11:31 UTC

    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

      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

Re^3: How to use synchronize method with WWW::Mechanize::Firefox?
by nysus (Parson) on Mar 27, 2016 at 10:36 UTC

    I've also tried the following:

    $self->synchronize( 'DOMContentLoaded', sub { $self->submit_form( with +_fields => {log => 'admin', pwd => 'password'} ) } );

    The submit_form gets called and the next page loads but then the script just hangs.

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