in reply to WWW::Mechanize::Firefox not filling out form
This is a deficiency and maybe even a bug in ->set_fields(). I think ->set_fields needs more tests, as <input type="radio"> fields are not really supported by ->field or ->select.
As a workaround, the following script works for me. It uses ->field() to set the sequence and explicitly ->clicks on the radio input, because that's what the Javascript code expects to happen.
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() ) { print "Retrieved $url\n"; $agent->form_name('form1'); #$agent->set_fields( 'sequence' => $seq ); $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 ); #$agent->submit(); }
Update: Confirmed: ->set_fields() has a bug in it and never worked at all. The next release (0.41) will have tests and likely a somewhat more working version of ->set_fields but you should do without it for the time being. Thanks for providing such a convenient, almost self-contained example that replicates the problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: WWW::Mechanize::Firefox not filling out form
by Anonymous Monk on Dec 10, 2010 at 16:22 UTC | |
by Corion (Patriarch) on Dec 10, 2010 at 18:59 UTC | |
by Anonymous Monk on Dec 10, 2010 at 19:07 UTC | |
by Corion (Patriarch) on Dec 10, 2010 at 19:44 UTC |