in reply to Re: WWW::Mechanize::Firefox not filling out form
in thread WWW::Mechanize::Firefox not filling out form

Thanks for this. The form now shows data being entered into it, but then Firefox (32-bit Windows version 3.6.12) starts eating up an entire CPU core on my computer and never moves on from clicking the radio button in the script. I can tell that it is the interaction of this script with Firefox since if I break (^C) the script, Firefox immediately drops in CPU usage.
  • Comment on Re^2: WWW::Mechanize::Firefox not filling out form

Replies are listed 'Best First'.
Re^3: WWW::Mechanize::Firefox not filling out form
by Corion (Patriarch) on Dec 10, 2010 at 18:59 UTC

    I can't reproduce your problem.

    My script, as posted above, does not do that, in fact, it never submits because that's commented out. To help me help you better, you could post a minimal version of your script that still reproduces the problem but is no longer than 20 lines. That would enable me, again, to reproduce your problem and maybe find a diagnosis that helps us determine the best approach to a solution.

      My apologies. Here's the code example. It inputs the text into the text box and selects the correct radio button and then Firefox goes to 100% usage on a single core.
      use strict; use WWW::Mechanize::Firefox; my $url = "http://tools.immuneepitope.org/tools/bcell/iedb_input"; my $agent = WWW::Mechanize::Firefox->new( activate => 1, autoclose => 0, ); my $method = 49; my $seq = "ARRRSFASDATRASDFSDARASDAGADFGASDRFREWFASCDSAGAREW"; $agent->get($url); if ( $agent->success() ) { sleep(5); print "Retrieved $url\n"; $agent->form_name('form1'); #$agent->set_fields( 'sequence' => $seq,'method' => $method); $agent->field( 'sequence' => $seq ); my $q = sprintf '//input[@name="method" and @value="%s"]', $method +; my $method_field = $agent->xpath( $q, single => 1 ); $agent->click( $method_field, synchronize => 0 ); sleep(5); $agent->submit(); }

        Ah - again, it's my error, as the API for ->click() does not want a hash but a hash reference when passing in elements and instructions for "blindly" clicking things. I've taken out your calls to sleep and added some warnings for the progress. The main change is from

        $agent->click($method_field, synchronize => 0 );
        to
        $agent->click({ dom => $method_field, synchronize => 0 });
        use strict; use WWW::Mechanize::Firefox; my $url = "http://tools.immuneepitope.org/tools/bcell/iedb_input"; my $agent = WWW::Mechanize::Firefox->new( activate => 1, autoclose => 0, ); my $method = 49; my $seq = "ARRRSFASDATRASDFSDARASDAGADFGASDRFREWFASCDSAGAREW"; $agent->get($url); if ( $agent->success() ) { #sleep(5); print "Retrieved $url\n"; $agent->form_name('form1'); #$agent->set_fields( 'sequence' => $seq,'method' => $method); $agent->field( 'sequence' => $seq ); my $q = sprintf '//input[@name="method" and @value="%s"]', $method +; my $method_field = $agent->xpath( $q, single => 1 ); warn "Method"; $agent->click({ dom => $method_field, synchronize => 0 }); #sleep(5); warn "Submitting"; $agent->submit(); }