Hi Craig,
this reproduction scenario is far too complicated to be included as unit
test ;-(
You should ask on htmlunit mailing list. Personally I haven't had time
until now for this.
Marc.
Craig Copeland wrote:
A reproduction scenario for a htmlunit issue has just been added to the bug
below:
https://sourceforge.net/tracker/index.php?func=detail&aid=1531821&group_id=47038&atid=448266
Would it be possible for someone to look into this?
Reproduction scenario:
0. Perl installed (5.8.8)
1. Run a perl script attached (see below - "mini" web server)
2. Run webtest with test.xml (see below)
===> BUILD FAILED
C:\Documents and Settings\ccopeland\Desktop\canoo-webtest\tests\test.xml:11: Ca
oo Webtest: R_1375.
Test failed.
Test step clickButton (C:\Documents and Settings\ccopeland\Desktop\canoo-webtes
\tests\test.xml:24: ) failed with message "Step[clickButton (3/4)]: HTTP error
302, at: clickButton"
at com.canoo.webtest.ant.WebtestTask.stopBuildIfNeeded(WebtestTask.java
186)
at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:155)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultEx
cutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Total time: 2 seconds
==================================================================
httpdebug.pl
==================================================================
#!/usr/bin/perl -w
#-------------------------------------------------------
# HTTP Debugger
#
# Just a little test for 302 redirection back to the
# same page. I've been using WinXP with Perl v5.8.8
# Thanks to John Nolan for the bulk of this code.
#-------------------------------------------------------
use CGI qw(:standard :noDebug);
use HTTP::Daemon;
use HTTP::Status;
use HTTP::Request;
use LWP::UserAgent;
use Getopt::Std;
use Sys::Hostname;
use strict;
use vars qw( $opt_h $opt_p $opt_t $Progname );
$|++;
getopts('h:p:t:');
#----------------------------------------------
# Setup Global variables
#
my $PORT = (defined $opt_p ? $opt_p : 0 );
my $TIMEOUT = (defined $opt_t ? $opt_t : 300 );
my $HOST = (defined $opt_h ? $opt_h : hostname() );
chomp($HOST);
my $d = new HTTP::Daemon (LocalAddr => $HOST);
$d = new HTTP::Daemon (LocalAddr => $HOST, LocalPort => $PORT) if $PORT;
unless (defined $d) {
warn "Could not bind to port $PORT. I'm going to have to exit.
Sorry.\n";
exit(-1);
}
$PORT = $d->sockport;
my $url = $d->url;
my $agentname = "Mozilla (compatible: LWP $LWP::VERSION)";
my %res_headers; # Hash will hold response headers that we serve
my %res_content; # Hash will hold response content that we serve
# This function sets up the variables containing all
# the sample docs are initialized.
#
setup_samples();
# The default test doc is a nice short simple HTML doc.
#
$res_headers{'current'} = ($res_headers{'HTML simple'} or "");
$res_content{'current'} = ($res_content{'HTML simple'} or "<H1>Oops -- test no
data!</H1>");
#----------------------------------------------
# Daemonize: fork, and then detatch from the local shell.
#
defined(my $pid = fork) or die "Cannot fork: $!";
if ($pid) { # The parent exits
print redirect($url);
exit 0;
}
#close(STDOUT); # The child lives on, but disconnects
# from the local terminal if uncommented
# We opt not to close STDERR here, because we actually might
# want to see error messages at the terminal.
#----------------------------------------------
# MAIN LOGIC: Basically a never-ending listen loop
#
LISTEN: {
alarm($TIMEOUT); # (re-)set the deadman timer
my $c = $d->accept; # $c is a connection
redo LISTEN unless defined $c;
my $r = $c->get_request; # $r is a request
redo LISTEN unless defined $r;
$CGI::Q = new CGI $r->content;
#--------------------
my $page1 = "";
my $param1 = "";
($page1, $param1) = split(/\&/, $r->uri);
my $tmptmp = $url . substr($r->uri,1);
print $tmptmp . "\n";
my $trash1 = "";
my $content1 = "";
($content1,$trash1) = split(/\&/, $r->content);
if (($page1) && ($page1 =~ /(^\/redirectThisPage$)/)) {
if (($content1) && ($content1 =~ /(^method=addSave$)/)) {
print "content = " . $content1 . "\n";
print "Sending the 302\n";
print $res_headers{'My 302 Redirect'} . "\n" . $res_content{'My
302
Redirect'};
print $c
$res_headers{'My 302 Redirect'} . "\n" .
$res_content{'My 302 Redirect'}
;
close $c;
redo LISTEN;
} elsif (($param1) && ($param1 =~ /(^page=post$)/)) {
print "Establish the initial POST\n";
print $c
$res_headers{'My HTML Form'} . "\n" . $res_content{'My
HTML Form'}
;
close $c;
redo LISTEN;
} else {
print "Send the normal page\n";
print $c
$res_headers{'HTML simple'} . "\n" . $res_content{'HTML
simple'}
;
close $c;
redo LISTEN;
}
} else {
print "Sending the normal page\n";
print $c
$res_headers{'HTML simple'} . "\n" . $res_content{'HTML
simple'}
;
close $c;
redo LISTEN;
}
}
#----------------------------------------------
# Set up the sample test pages.
#
sub setup_samples {
$Progname = "HTTP Debugger";
#----------------------------------
$res_headers{'My HTML Form'} =<<EOM;
HTTP/1.1 200 OK
Date: Sat, 20 Feb 1999 16:59:12 GMT
Server: libwww-perl-daemon
Content-Type: text/html
EOM
$res_content{'My HTML Form'} =<<EOM;
<HTML><HEAD><TITLE>$Progname - form</TITLE>
</HEAD><BODY>
<H2>Hello client! I'm an HTML Form.
</H2>
<FORM method="post" action="redirectThisPage">
<input type="hidden" name="method" value="addSave"/>
<input type="submit" name="submit" value="Submit"/>
</FORM>
</BODY></HTML>
EOM
#----------------------------------
$res_headers{'My 302 Redirect'} =<<EOM;
HTTP/1.1 302 Found
Date: Sat, 18 Dec 1999 23:38:49 GMT
Server: Apache/1.3.9 (Unix)
Location: http://$HOST:$PORT/redirectThisPage
Connection: close
Content-Type: text/html
EOM
$res_content{'My 302 Redirect'} =<<EOM;
<HTML><HEAD>
<TITLE>302 Found</TITLE>
</HEAD><BODY>
<H1>Found</H1>
The document has moved <A
HREF="http://$HOST:$PORT/redirectThisPage">here</A>.<P>
<HR>
</BODY></HTML>
EOM
#----------------------------------
$res_headers{'HTML simple'} =<<EOM;
HTTP/1.1 200 OK
Date: Sat, 20 Feb 1999 16:59:12 GMT
Server: libwww-perl-daemon
Content-Type: text/html
EOM
$res_content{'HTML simple'} =<<EOM;
<HTML><HEAD><TITLE>$Progname - file</TITLE>
</HEAD><BODY>
<H2>Hello client! I'm an HTML file.
</H2>
To test the 302 redirect via an HTML POST,
<A HREF="redirectThisPage&page=post">
click here</A>
</BODY></HTML>
EOM
}
==================================================================
test.xml
==================================================================
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "WebTest.dtd"[
]>
<project name="Testing 1.2.3" basedir="." default="main">
<property name="webtest.home" location="C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest"/>
<import file="${webtest.home}/lib/taskdef.xml"/>
<target name="main">
<webtest name="myTest">
<config
host="ws-ccopeland"
port="8888"
summary="true"
saveresponse="true"
protocol="http"/>
<steps>
<invoke
url="redirectThisPage&page=post"/>
<verifyTitle
text="HTTP Debugger - form"/>
<clickButton
name="submit"/>
<verifyTitle
text="HTTP Debugger - file"/>
</steps>
</webtest>
</target>
</project>
==================================================================
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest