242
242
if exists $attr->{$_};
244
244
# count this new select option separately
245
$openselect{$attr->{name}}++;
245
my $name = $attr->{name};
246
$name = "" unless defined $name;
247
$openselect{$name}++;
247
249
while ($t = $p->get_tag) {
248
250
my $tag = shift @$t;
262
264
$a{value_name} = $p->get_trimmed_text;
263
265
$a{value} = delete $a{value_name}
264
266
unless defined $a{value};
265
$a{idx} = $openselect{$attr->{name}};
267
$a{idx} = $openselect{$name};
266
268
$f->push_input("option", \%a, $verbose);
455
=item $input = $form->find_input( $name )
457
=item $input = $form->find_input( $name, $type )
459
=item $input = $form->find_input( $name, $type, $index )
457
=item $input = $form->find_input( $selector )
459
=item $input = $form->find_input( $selector, $type )
461
=item $input = $form->find_input( $selector, $type, $index )
461
463
This method is used to locate specific inputs within the form. All
462
464
inputs that match the arguments given are returned. In scalar context
463
465
only the first is returned, or C<undef> if none match.
465
If $name is specified, then the input must have the indicated name.
467
If $selector is specified, then the input's name, id, class attribute must
468
match. A selector prefixed with '#' must match the id attribute of the input.
469
A selector prefixed with '.' matches the class attribute. A selector prefixed
470
with '^' or with no prefix matches the name attribute.
467
472
If $type is specified, then the input must have the specified type.
468
473
The following type names are used: "text", "password", "hidden",
483
488
for (@{$self->{'inputs'}}) {
485
next unless exists $_->{name};
486
next if $name ne $_->{name};
489
next if defined($name) && !$_->selected($name);
488
490
next if $type && $type ne $_->{type};
490
492
next if $no && $no != $c;
498
500
for (@{$self->{'inputs'}}) {
500
next unless exists $_->{name};
501
next if $name ne $_->{name};
501
next if defined($name) && !$_->selected($name);
503
502
next if $type && $type ne $_->{type};
520
=item $value = $form->value( $name )
519
=item $value = $form->value( $selector )
522
=item $form->value( $name, $new_value )
521
=item $form->value( $selector, $new_value )
524
523
The value() method can be used to get/set the value of some input. If
525
524
strict is enabled and no input has the indicated name, then this method will croak.
721
720
=item $request = $form->click
723
=item $request = $form->click( $name )
722
=item $request = $form->click( $selector )
725
724
=item $request = $form->click( $x, $y )
727
=item $request = $form->click( $name, $x, $y )
726
=item $request = $form->click( $selector, $x, $y )
729
728
Will "click" on the first clickable input (which will be of type
730
729
C<submit> or C<image>). The result of clicking is an C<HTTP::Request>
731
730
object that can then be passed to C<LWP::UserAgent> if you want to
732
731
obtain the server response.
734
If a $name is specified, we will click on the first clickable input
735
with the given name, and the method will croak if no clickable input
736
with the given name is found. If $name is I<not> specified, then it
733
If a $selector is specified, we will click on the first clickable input
734
matching the selector, and the method will croak if no matching clickable
735
input is found. If $selector is I<not> specified, then it
737
736
is ok if the form contains no clickable inputs. In this case the
738
737
click() method returns the same request as the make_request() method
738
would do. See description of the find_input() method above for how
739
the $selector is specified.
741
741
If there are multiple clickable inputs with the same name, then there
742
742
is no way to get the click() method of the C<HTML::Form> to click on
761
761
# try to find first submit button to activate
762
762
for (@{$self->{'inputs'}}) {
763
763
next unless $_->can("click");
764
next if $name && $_->name ne $name;
764
next if $name && !$_->selected($name);
765
765
next if $_->disabled;
766
766
return $_->click($self, @_);
897
897
This method can be used to get/set the current name of the input.
903
These methods can be used to get/set the current id or class attribute for the input.
905
=item $input->selected( $selector )
907
Returns TRUE if the given selector matched the input. See the description of
908
the find_input() method above for a description of the selector syntax.
899
910
=item $value = $input->value
901
912
=item $input->value( $new_value )
937
my $old = $self->{id};
938
$self->{id} = shift if @_;
945
my $old = $self->{class};
946
$self->{class} = shift if @_;
951
my($self, $sel) = @_;
952
return undef unless defined $sel;
954
$sel =~ s/^\^// ? "name" :
955
$sel =~ s/^#// ? "id" :
956
$sel =~ s/^\.// ? "class" :
958
return 0 unless defined $self->{$attr};
959
return $self->{$attr} eq $sel;
925
964
my $self = shift;