Update of /cvsroot/http-webtest/HTTP-WebTest/t
In directory usw-pr-cvs1:/tmp/cvs-serv11084/t
Modified Files:
test3.txt test2.html.in 10-click.t
Added Files:
test3.html
Log Message:
Added tests for click_button
--- NEW FILE: test3.html ---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test File 3</title>
</head>
<body>
<form action="/test1.txt">
<input type="submit" name="Button1">
<input name="NonButton">
</form>
<form action="/test2.txt">
<input type="submit" value="Button2">
</form>
</body>
</html>
Index: test3.txt
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/t/test3.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test3.txt 21 Feb 2002 01:43:35 -0000 1.1
--- test3.txt 27 Apr 2002 21:17:20 -0000 1.2
***************
*** 9,12 ****
--- 9,16 ----
<a href="test2.html">Test 2</a>
+ <form action="/test1.txt">
+ <input type="submit" name="Button1">
+ </form>
+
</body>
</html>
Index: test2.html.in
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/t/test2.html.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test2.html.in 21 Feb 2002 01:43:35 -0000 1.1
--- test2.html.in 27 Apr 2002 21:17:20 -0000 1.2
***************
*** 6,12 ****
</head>
- <a href="alttest1.txt">Text File</a>
-
<body>
</body>
</html>
--- 6,11 ----
</head>
<body>
+ <a href="alttest1.txt">Text File</a>
</body>
</html>
Index: 10-click.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/t/10-click.t,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** 10-click.t 27 Apr 2002 20:37:48 -0000 1.4
--- 10-click.t 27 Apr 2002 21:17:20 -0000 1.5
***************
*** 16,20 ****
use vars qw($HOSTNAME $PORT $URL $TEST);
! BEGIN { plan tests => 3 }
# init tests
--- 16,20 ----
use vars qw($HOSTNAME $PORT $URL $TEST);
! BEGIN { plan tests => 6 }
# init tests
***************
*** 65,70 ****
# 3: test missing link
{
- generate_testfile(file => 't/test2.html', server_url => $URL);
-
my $tests = [ { url => abs_url($URL, '/test1.html'),
text_require => [ '<title>Test File 1</title>' ] },
--- 65,68 ----
***************
*** 81,84 ****
--- 79,134 ----
}
+ # 4: test clicking submit buttons in forms
+ {
+ my $tests = [ { url => abs_url($URL, '/test3.html'),
+ text_require => [ '<title>Test File 3</title>' ] },
+ # click button to submit form to /test1.txt
+ { click_button => 'Button1',
+ text_require => [ 'abcde' ] },
+ { url => abs_url($URL, '/test3.html'),
+ text_require => [ '<title>Test File 3</title>' ] },
+ # click another button to submit form to /test2.txt
+ { click_button => 'Button2',
+ text_require => [ 'begin 644' ] }
+ ];
+
+ check_webtest(webtest => $WEBTEST,
+ server_url => $URL,
+ tests => $tests,
+ opts => $OPTS,
+ check_file => 't/test.out/click_button1');
+ }
+
+ # 5: clicking submit buttons in non HTML pages should not work
+ {
+ my $tests = [ { url => abs_url($URL, '/test3.txt'),
+ text_require => [ '<a href="test2.html">Test 2</a>' ] },
+ { click_button => 'Button1',
+ text_forbid => [ 'abcde' ] },
+ ];
+
+ catch_webtest(webtest => $WEBTEST,
+ server_url => $URL,
+ tests => $tests,
+ opts => $OPTS,
+ check_file => 't/test.out/click_button2');
+ }
+
+ # 6: clicking non-existing button
+ {
+ my $tests = [ { url => abs_url($URL, '/test3.html'),
+ text_require => [ '<title>Test File 3</title>' ] },
+ # try to specify non-submit input control
+ { click_button => 'NonButton',
+ text_require => [ 'abcde' ] },
+ ];
+
+ catch_webtest(webtest => $WEBTEST,
+ server_url => $URL,
+ tests => $tests,
+ opts => $OPTS,
+ check_file => 't/test.out/click_button3');
+ }
+
# try to stop server even we have been crashed
END { stop_webserver($PID) if defined $PID }
***************
*** 95,104 ****
if($path =~ m(/test1.txt|/dir/alttest1.txt)) {
$connect->send_file_response('t/test1.txt');
! } elsif($path eq '/test3.txt') {
! $connect->send_file_response('t/test3.txt');
! } elsif($path eq '/test1.html' ) {
! $connect->send_file_response('t/test1.html');
! } elsif($path eq '/test2.html' ) {
! $connect->send_file_response('t/test2.html');
} else {
$connect->send_error(RC_NOT_FOUND);
--- 145,150 ----
if($path =~ m(/test1.txt|/dir/alttest1.txt)) {
$connect->send_file_response('t/test1.txt');
! } elsif($path =~ m|^/test\d+.\w+$|) {
! $connect->send_file_response('t' . $path);
} else {
$connect->send_error(RC_NOT_FOUND);
|