Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 43815
Status: resolved
Worked: 10 min
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors: descartavel1 [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: select a form by the id attribute
most websites today use only the id attribute on forms. not the name.
Patch to make Mechanize understand form_id instead of form_name. Most of the code was already there (e.g. unused sub form_id). It does not check for name/id clash or consistency. if you provide both, name has precedence and that's it.
--- /home/gbarros/Mechanize.pm 2009-03-03 16:19:05.000000000 -0300 +++ ./Mechanize.pm 2009-03-03 15:49:46.000000000 -0300 @@ -1797,7 +1797,7 @@ my( $self, %args ) = @_ ; for ( keys %args ) { - if ( !/^(form_(number|name|fields)|(with_)?fields|button|x|y)$/ ) { + if ( !/^(form_(number|name|fields|id)|(with_)?fields|button|x|y)$/ ) { # XXX Why not die here? $self->warn( qq{Unknown submit_form parameter "$_"} ); } @@ -1826,6 +1826,9 @@ elsif ( my $form_name = $args{'form_name'} ) { $self->form_name( $form_name ) or die qq{There is no form named "$form_name"}; } + elsif ( my $form_id = $args{'form_id'} ) { + $self->form_id( $form_id ) or die qq{There is no form IDed "$form_id"}; + } else { # No form selector was used. # Maybe a form was set separately, or we'll default to the first form.
Added. Thanks for the patch. Future tickets should go to http://code.google.com/p/www-mechanize/issues/list, please.