Update of /cvsroot/http-webtest/HTTP-WebTest/lib/HTTP/WebTest/Plugin
In directory usw-pr-cvs1:/tmp/cvs-serv21691/lib/HTTP/WebTest/Plugin
Modified Files:
Click.pm
Log Message:
Support image buttons; add support for test parameter 'form_name'
Index: Click.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/lib/HTTP/WebTest/Plugin/Click.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Click.pm 15 Aug 2002 17:21:08 -0000 1.13
--- Click.pm 20 Aug 2002 20:58:36 -0000 1.14
***************
*** 38,44 ****
=head2 click_button
! Given name of submit button (i.e. C<<input type="submit"E<gt>> tag
! inside of C<<formE<gt>> tag) on previosly requested HTML page, builds
! test request to the submitted page.
Note that you still need to pass all form parameters yourself using
--- 38,44 ----
=head2 click_button
! Given name of submit button (i.e. C<<input type="submit"E<gt>> tag or
! C<<input type="image"E<gt>> inside of C<<formE<gt>> tag) on previously
! requested HTML page, builds test request to the submitted page.
Note that you still need to pass all form parameters yourself using
***************
*** 58,66 ****
See example in L<HTTP::WebTest::Cookbook|HTTP::WebTest::Cookbook>.
=cut
sub param_types {
return q(click_button scalar
! click_link scalar);
}
--- 58,75 ----
See example in L<HTTP::WebTest::Cookbook|HTTP::WebTest::Cookbook>.
+ =head2 form_name
+
+ Give form name attribute (i.e. C<<form name="foo"E<gt>>) on previously
+ requested HTML page, builds test request to the submitted page.
+
+ Note that you still need to pass all form parameters yourself using
+ C<params> test parameter.
+
=cut
sub param_types {
return q(click_button scalar
! click_link scalar
! form_name scalar);
}
***************
*** 68,72 ****
my $self = shift;
! $self->validate_params(qw(click_button click_link));
# get current request object
--- 77,81 ----
my $self = shift;
! $self->validate_params(qw(click_button click_link form_name));
# get current request object
***************
*** 89,92 ****
--- 98,102 ----
my $click_button = $self->test_param('click_button');
my $click_link = $self->test_param('click_link');
+ my $form_name = $self->test_param('form_name');
if(defined $click_link) {
***************
*** 104,107 ****
--- 114,124 ----
$request->base_uri($action)
if defined $action;
+ } elsif(defined $form_name) {
+ # find action which corresponds to requested form name
+ my $action = $self->find_form(response => $response,
+ form_name => $form_name);
+
+ $request->base_uri($action)
+ if defined $action;
}
}
***************
*** 165,168 ****
--- 182,186 ----
my $response = $param{response};
my $pattern = $param{pattern};
+ my $form_name = $param{form_name};
my $base = $self->find_base($response);
***************
*** 177,180 ****
--- 195,204 ----
my $action = $token->[1]{action} || $base;
+ if ( $token->[1]{name} and $form_name
+ and ( $token->[1]{name} eq $form_name ) ){
+ $uri = $action;
+ last FORM;
+ }
+ next unless $pattern;
# find matching submit button or end of form
while(my $token = $parser->get_tag('input', '/form')) {
***************
*** 187,195 ****
# check if right input control is found
! my $type = $token->[1]{type} || 'text';
! my $name = $token->[1]{name} || '';
my $value = $token->[1]{value} || '';
! next unless lc($type) eq 'submit';
! next unless $name =~ /$pattern/i or $value =~ /$pattern/i;
# stop searching
--- 211,220 ----
# check if right input control is found
! my $type = $token->[1]{type} || 'text';
! my $name = $token->[1]{name} || '';
my $value = $token->[1]{value} || '';
! my $src = $token->[1]{src} || ''; # to handle image submit button
! next unless $type =~ /^(?:submit|image)$/i;
! next unless grep /$pattern/i, $name, $value, $src;
# stop searching
|