nysus has asked for the wisdom of the Perl Monks concerning the following question:

I've got a form in WordPress that uses the "Chosen" jquery plugin for drop down <select> fields. I'm having a tough time automating these fields with WWW::Mechanize::Firefox. The website for the plugin is here.

When I click on the div tag associated with the drop down, it just hangs. Here is the code I'm using to click on it:

$mech->click({xpath => '//div[@id="saved_venue_chosen"]'}, synchronize + => 0);

The synchronize => 0 bit is supposed to prevent the script from waiting for a response from the server. However, I'm thinking that because clicking on the div tag causes jquery to change the classes of the div tag, it might be confusing WWW::Mechanize::Firefox.

I tried this:

my $i = $mech->xpath('//div[@id="saved_venue_chosen"]', one => 1); + $i->__event('focus'); $i->__event('click');

It didn't work. Any other workarounds I might try?

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

Replies are listed 'Best First'.
Re: WWW::Mechanize::Firefox hangs when jquery element clicked
by nysus (Parson) on Feb 12, 2016 at 13:29 UTC

    OK, got it. Needed a 'mousedown' event like so:

    $i->__event('mousedown');

    Hopefully this will save someone the hours of time I lost on this one.

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