Hi Craig,
I've checked and htmlunit sets correctly form fields named "method".
Therefore I guess that you're right and that it has to do with the 302
that htmlunit skips. I suppose that you get a warning like:
Got a redirect but the location is the same as the page we just loaded
[...]. Skipping redirection.
As workaround as long htmlunit is not more tolerant, you can use:
<groovy>
step.context.webClient.throwExceptionOnFailingStatusCode = false
</groovy>
<yourstep>
<groovy description="set it back">
step.context.webClient.throwExceptionOnFailingStatusCode = true
</groovy>
or if you need it through the whole script as option in the config:
<config ...>
<option name="ThrowExceptionOnFailingStatusCode" value="false"/>
</groovy>
</config>
Marc.
Craig Copeland wrote:
Howdy Marc,
Yes, you are exactly right. There is indeed a hidden field on the page called
"method". (It's becoming more obvious that this isn't my code. :-) This field
is used on the server side. Sorry about the confusion.
So if you don't mind let me reiterate what I'm seeing with IE and with webtest.
With IE (or FF, etc) the steps of communication are as follows:
1. The Add (i.e., Submit) button is clicked and a POST is sent to the server.
(<form method="post" action=...>)
2. After processing the request, the Server returns a 302 message with a URL of
the previous page. (HTTP/1.1 302 Moved Temporarily)
3. Then the browser code submits a GET to the location provided in the initial
302 response. (GET /admin/webLink.do HTTP/1.1)
4. And finally the server sends the requested page (HTTP/1.1 200 OK)
To ensure that this is actually happening, I'm running wireshark (fka
ethereal), to see exactly what's being sent over the wire, which looks like
this with IE:
1. ---Initial POST---
POST /admin/webLink.do HTTP/1.1\r\n
... (other parameters) ...
Content-Length: 52\r\n
\r\n
name=asdfasdf&url=asdfasdf&method=addSave&isSubEdit=
2. ---Initial Server Response---
HTTP/1.1 302 Moved Temporarily\r\n
Cache-Control: no-cache\r\n
Location: http://172.16.34.36:8080/admin/webLink.do\r\n
Content-Type: text/html\r\n
Content-Length: 0\r\n
Date: Wed, 26 Jul 2006 16:21:05 GMT\r\n
Server: Apache-Coyote/1.1\r\n
\r\n
3. ---Subsequent GET---
GET /admin/webLink.do HTTP/1.1\r\n
... (other parameters) ...
\r\n
4. ---Final Server Response with webLink.do---
HTTP/1.1 200 OK\r\n
Cache-Control: no-cache\r\n
Content-Type: text/html\r\n
Transfer-Encoding: chunked\r\n
Date: Wed, 26 Jul 2006 16:21:06 GMT\r\n
Server: Apache-Coyote/1.1\r\n
\r\n
<html>\r\n
... (remainder html document)...
However, when I use webtest/htmlunit as my browser I get #1 and #2, but then #3
is never sent.
As for the debugging run, here's what I got.
C:\Documents and Settings\ccopeland\Desktop\canoo-webtest\tests>webtest -d -v
-b
uildfile CRUD-Web_Link.xml
"C:\Program Files\java\jdk1.5.0_06\bin\java.exe" -Xms64M -Xmx256M -cp
"C:\Docume
nts and Settings\ccopeland\Desktop\canoo-webtest\bin\..\lib\ant-launcher.jar"
-D
ant.library.dir="C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest\bin\.
.\lib" org.apache.tools.ant.launch.Launcher -nouserlib -lib "C:\Documents and
Se
ttings\ccopeland\Desktop\canoo-webtest\bin\..\lib\build;C:\Documents and
Setting
s\ccopeland\Desktop\canoo-webtest\bin\..\lib\build\clover.jar" -d -v -buildfile
CRUD-Web_Link.xml
Apache Ant version 1.6.5 compiled on June 2 2005
Apache Ant version 1.6.5 compiled on June 2 2005
Buildfile: CRUD-Web_Link.xml
Detected Java version: 1.5 in: C:\Program Files\java\jdk1.5.0_06\jre
Detected OS: Windows XP
parsing buildfile C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest\test
s\CRUD-Web_Link.xml with URI =
file:///C:/Documents%20and%20Settings/ccopeland/D
esktop/canoo-webtest/tests/CRUD-Web_Link.xml
resolving systemId:
file:///C:/Documents%20and%20Settings/ccopeland/Desktop/cano
o-webtest/tests/WebTest.dtd
Project base dir set to: C:\Documents and
Settings\ccopeland\Desktop\canoo-webte
st\tests
resolving systemId:
file:///C:/Documents%20and%20Settings/ccopeland/Desktop/cano
o-webtest/tests/config.xml
resolving systemId:
file:///C:/Documents%20and%20Settings/ccopeland/Desktop/cano
o-webtest/tests/login.xml
resolving systemId:
file:///C:/Documents%20and%20Settings/ccopeland/Desktop/cano
o-webtest/tests/config.xml
resolving systemId:
file:///C:/Documents%20and%20Settings/ccopeland/Desktop/cano
o-webtest/tests/login.xml
resolving systemId:
file:///C:/Documents%20and%20Settings/ccopeland/Desktop/cano
o-webtest/tests/config.xml
resolving systemId:
file:///C:/Documents%20and%20Settings/ccopeland/Desktop/cano
o-webtest/tests/login.xml
resolving systemId:
file:///C:/Documents%20and%20Settings/ccopeland/Desktop/cano
o-webtest/tests/config.xml
resolving systemId:
file:///C:/Documents%20and%20Settings/ccopeland/Desktop/cano
o-webtest/tests/login.xml
Importing file C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest/lib/tas
kdef.xml from C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest\tests\CR
UD-Web_Link.xml
parsing buildfile C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest\lib\
taskdef.xml with URI =
file:///C:/Documents%20and%20Settings/ccopeland/Desktop/c
anoo-webtest/lib/taskdef.xml
Importing file C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest\lib/cla
sspath.xml from C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest\lib\ta
skdef.xml
parsing buildfile C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest\lib\
classpath.xml with URI =
file:///C:/Documents%20and%20Settings/ccopeland/Desktop
/canoo-webtest/lib/classpath.xml
Trying to override old definition of task sleep
Build sequence for target(s) `main' is [main]
Complete build sequence is [main, ]
main:
BUILD FAILED
C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest\tests\CRUD-Web_Link.xm
l:16: Canoo Webtest: R_1365.
Test failed.
Test step clickButton (C:\Documents and
Settings\ccopeland\Desktop\canoo-webtest
\tests\CRUD-Web_Link.xml:46: ) named "Click the Add button for Web Links"
faile
d with message "Step[clickButton "Click the Add button for Web Links" (14/19)]:
Script error loading page executing webtest at: clickButton Wrapped
com.gargoyle
software.htmlunit.FailingHttpStatusCodeException: 302 Moved Temporarily for
http
://172.16.34.36:8080/admin/webLink.do
(http://172.16.34.36:8080/admin/scripts/co
mmon.js#667)
Source code:
function () {
[native code, arity=0]
}
"
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(DefaultExe
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: 9 seconds
Thanks again Marc,
Craig
Hi Craig,
I confirm that unless "method" is an input field of your form,
form.method.value is not correct (neither with IE nor with FF).
Unless you have configured WebClient's redirection settings, a 302 should be
followed even for js code. Can you change the log level to debug, you should
see a bit more on the console, like "Got a redirect status code ...".
I can't say anything concerning the addSave as it is highly bound to your js
code.
Marc.
__________________________________________________
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