[Webtest] __doPostBack function for ASP forms
Florent Blondeau
Florent Blondeau <fblondeau@pingwy.com>
Wed, 05 Dec 2007 17:54:35 +0100
This is a multi-part message in MIME format.
--------------030705090104050205030608
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Merci Marc, really, thanks a lot...
So, my problem is not solved, but I think you've found the cause.
The form is nested into another form !!!!!!!!!!!!!! And this form has
5 or 6 hidden input fields that appear in the Browser request, but
not in Webtest request. That's like that
<form name="parentform">
<input type="hidden" name="totohidden"
value="ahahthisisyoursessionvalue">
<form name="childform">
<input type="submit" name="totonothidden">
</form>
</form>
I think the normal browser submit the parent form as well as the
selected form.
I don't think it is absolutely "w3c"
Then, as the solution is very close, I have the last question :
How can I submit the parent form (post method, with hidden fields, etc)
and not the childform(get method, no knowledge of hidden fields) ?
I tried a selectForm on the parent, it worked (form is well selected),
but when I perform the clickButton method, I have :
*
DEBUG (com.canoo.webtest.steps.Step) - <<<< Successful Step: selectForm
(52/54)
DEBUG (com.canoo.webtest.reporting.StepExecutionListener) -
fPreviousCurrentResponse: HtmlPage(http://.....)@31541880
DEBUG (com.canoo.webtest.reporting.StepExecutionListener) -
fContext.getCurrentResponse(): HtmlPage(http://....)@31541880
DEBUG (com.canoo.webtest.reporting.StepExecutionListener) -
isWorthSaving: false, false
DEBUG (com.canoo.webtest.ant.TestStepSequence) - Executing step
clickButton org.apache.tools.ant.UnknownElement@1e514a9
INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: clickButton (53/54)
DEBUG (com.canoo.webtest.steps.request.AbstractIdOrLabelTarget) -
Looking for html element with id: button_id
DEBUG (com.canoo.webtest.steps.request.ClickButton) - It's an image
input, that's ok
DEBUG (com.canoo.webtest.steps.request.ClickButton) - Button passes test
with label and name
INFO (com.canoo.webtest.steps.request.ClickButton) - -> findTarget(by
input): name=button_name value=
DEBUG (com.gargoylesoftware.htmlunit.html.HtmlPage) - Page Encoding
detected: windows-1252
DEBUG (com.gargoylesoftware.htmlunit.WebClient) - Get page for window
named '', using WebRequestSettings[<url="http://...",
SubmitMethod[name=get],
EncodingType[name=application/x-www-form-urlencoded], [],
{Referer=http://...}, null>]
DEBUG (com.gargoylesoftware.htmlunit.WebClient) - Load response for
http://...
DEBUG (org.apache.commons.httpclient.params.DefaultHttpParams) - Set
parameter http.authentication.credential-provider =
com.gargoylesoftware.htmlunit.DefaultCredentialsProvider@18aab40
DEBUG (org.apache.commons.httpclient.methods.GetMethod) - enter
GetMethod(String)
DEBUG (org.apache.commons.httpclient.params.DefaultHttpParams) - Set
parameter http.method.retry-handler =
com.gargoylesoftware.htmlunit.HttpWebConnection$1@6835fb
DEBUG (org.apache.commons.httpclient.HttpClient) - enter
HttpClient.executeMethod(HostConfiguration,HttpMethod)
DEBUG (org.apache.commons.httpclient.HttpClient) - enter
HttpClient.executeMethod(HostConfiguration,HttpMethod,HttpState)
DEBUG (org.apache.commons.httpclient.MultiThreadedHttpConnectionManager)
- enter
HttpConnectionManager.getConnectionWithTimeout(HostConfiguration, long)
DEBUG (org.apache.commons.httpclient.MultiThreadedHttpConnectionManager)
- HttpConnectionManager.getConnection: config =
HostConfiguration[host=http://...], timeout = 0
DEBUG (org.apache.commons.httpclient.MultiThreadedHttpConnectionManager)
- enter HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)
DEBUG (org.apache.commons.httpclient.MultiThreadedHttpConnectionManager)
- enter HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)
DEBUG (org.apache.commons.httpclient.MultiThreadedHttpConnectionManager)
- Getting free connection, hostConfig=HostConfiguration[host=http://...]
DEBUG (org.apache.commons.httpclient.HttpMethodDirector) - Attempt
number 1 to process request
DEBUG (org.apache.commons.httpclient.HttpConnection) - enter
HttpConnection.open()
DEBUG (org.apache.commons.httpclient.HttpConnection) - Open connection
to ...
DEBUG (org.apache.commons.httpclient.HttpMethodBase) - enter
HttpMethodBase.execute(HttpState, HttpConnection)
DEBUG (org.apache.commons.httpclient.HttpMethodBase) - enter
HttpMethodBase.writeRequest(HttpState, HttpConnection)
DEBUG (org.apache.commons.httpclient.HttpMethodBase) - enter
HttpMethodBase.writeRequestLine(HttpState, HttpConnection)
DEBUG (org.apache.commons.httpclient.HttpMethodBase) - enter
HttpMethodBase.generateRequestLine(HttpConnection, String, String,
String, String)
DEBUG (httpclient.wire.header) - >> "GET http://...?nothiddenfield=toto
HTTP/1.1[\r][\n]"
*That is not so weird, I think, since the button may reference its
parent form, does it ?
Do you see a workaround ? I'm too close to the goal, then I won't
surrender !!!!!!!!!
Thanks for reading
Marc Guillemot a écrit :
> Salut Florent,
>
> to understand what happens, you can try to look at the post details
> (url, fields and headers) both in WebTest and in a normal browser for
> your 9. step.
>
>
>> ...
>> Is there a way in Webtest to only trigger the Javascript of abutton
>> without sumitting the form
>>
>
> you can modify the html DOM to add inject for instance some onsubmit
> that returns false in your page, but I don't see what you would achieve
> with that.
>
>
>> (I think the navigation error come from the
>> fact the POST method is not Ajax called ) ?
>>
>
> ???
>
> Marc.
>
--
Pingwy
27, rue des arènes
49100 Angers
--------------030705090104050205030608
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Merci Marc, really, thanks a lot...<br>
<br>
So, my problem is not solved, but I think you've found the cause.<br>
<br>
The form is nested into another form !!!!!!!!!!!!!! And this form has <br>
5 or 6 hidden input fields that appear in the Browser request, but <br>
not in Webtest request. That's like that<br>
<form name="parentform"><br>
<input type="hidden" name="totohidden"
value="ahahthisisyoursessionvalue"><br>
<form name="childform"><br>
<input type="submit" name="totonothidden"><br>
</form><br>
</form><br>
<br>
I think the normal browser submit the parent form as well as the
selected form. <br>
I don't think it is absolutely "w3c"<br>
<br>
Then, as the solution is very close, I have the last question :<br>
<br>
How can I submit the parent form (post method, with hidden fields, etc)
and not the childform(get method, no knowledge of hidden fields) ?<br>
I tried a selectForm on the parent, it worked (form is well selected),
but when I perform the clickButton method, I have :<br>
<b><small><small><br>
DEBUG (com.canoo.webtest.steps.Step) - <<<< Successful
Step: selectForm (52/54)<br>
DEBUG (com.canoo.webtest.reporting.StepExecutionListener) -
fPreviousCurrentResponse: HtmlPage(<a class="moz-txt-link-freetext" href="http://.....)@31541880">http://.....)@31541880</a><br>
DEBUG (com.canoo.webtest.reporting.StepExecutionListener) -
fContext.getCurrentResponse(): HtmlPage(<a class="moz-txt-link-freetext" href="http://....)@31541880">http://....)@31541880</a><br>
DEBUG (com.canoo.webtest.reporting.StepExecutionListener) -
isWorthSaving: false, false<br>
DEBUG (com.canoo.webtest.ant.TestStepSequence) - Executing step
clickButton org.apache.tools.ant.UnknownElement@1e514a9<br>
INFO (com.canoo.webtest.steps.Step) - >>>> Start Step:
clickButton (53/54)<br>
DEBUG (com.canoo.webtest.steps.request.AbstractIdOrLabelTarget) -
Looking for html element with id: button_id<br>
DEBUG (com.canoo.webtest.steps.request.ClickButton) - It's an image
input, that's ok<br>
DEBUG (com.canoo.webtest.steps.request.ClickButton) - Button passes
test with label and name<br>
INFO (com.canoo.webtest.steps.request.ClickButton) - ->
findTarget(by input): name=button_name value=<br>
DEBUG (com.gargoylesoftware.htmlunit.html.HtmlPage) - Page Encoding
detected: windows-1252<br>
DEBUG (com.gargoylesoftware.htmlunit.WebClient) - Get page for window
named '', using WebRequestSettings[<url=<a class="moz-txt-link-rfc2396E" href="http://...">"http://..."</a>,
SubmitMethod[name=get],
EncodingType[name=application/x-www-form-urlencoded], [],
{Referer=<a class="moz-txt-link-freetext" href="http://">http://</a>...}, null>]<br>
DEBUG (com.gargoylesoftware.htmlunit.WebClient) - Load response for
<a class="moz-txt-link-freetext" href="http://">http://</a>...<br>
DEBUG (org.apache.commons.httpclient.params.DefaultHttpParams) - Set
parameter http.authentication.credential-provider =
com.gargoylesoftware.htmlunit.DefaultCredentialsProvider@18aab40<br>
DEBUG (org.apache.commons.httpclient.methods.GetMethod) - enter
GetMethod(String)<br>
DEBUG (org.apache.commons.httpclient.params.DefaultHttpParams) - Set
parameter http.method.retry-handler =
com.gargoylesoftware.htmlunit.HttpWebConnection$1@6835fb<br>
DEBUG (org.apache.commons.httpclient.HttpClient) - enter
HttpClient.executeMethod(HostConfiguration,HttpMethod)<br>
DEBUG (org.apache.commons.httpclient.HttpClient) - enter
HttpClient.executeMethod(HostConfiguration,HttpMethod,HttpState)<br>
DEBUG
(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager) -
enter HttpConnectionManager.getConnectionWithTimeout(HostConfiguration,
long)<br>
DEBUG
(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager) -
HttpConnectionManager.getConnection: config =
HostConfiguration[host=<a class="moz-txt-link-freetext" href="http://">http://</a>...], timeout = 0<br>
DEBUG
(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager) -
enter
HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)<br>
DEBUG
(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager) -
enter
HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)<br>
DEBUG
(org.apache.commons.httpclient.MultiThreadedHttpConnectionManager) -
Getting free connection, hostConfig=HostConfiguration[host=<a class="moz-txt-link-freetext" href="http://">http://</a>...]<br>
DEBUG (org.apache.commons.httpclient.HttpMethodDirector) - Attempt
number 1 to process request<br>
DEBUG (org.apache.commons.httpclient.HttpConnection) - enter
HttpConnection.open()<br>
DEBUG (org.apache.commons.httpclient.HttpConnection) - Open connection
to ...<br>
DEBUG (org.apache.commons.httpclient.HttpMethodBase) - enter
HttpMethodBase.execute(HttpState, HttpConnection)<br>
DEBUG (org.apache.commons.httpclient.HttpMethodBase) - enter
HttpMethodBase.writeRequest(HttpState, HttpConnection)<br>
DEBUG (org.apache.commons.httpclient.HttpMethodBase) - enter
HttpMethodBase.writeRequestLine(HttpState, HttpConnection)<br>
DEBUG (org.apache.commons.httpclient.HttpMethodBase) - enter
HttpMethodBase.generateRequestLine(HttpConnection, String, String,
String, String)<br>
DEBUG (httpclient.wire.header) - >> "GET
<a class="moz-txt-link-freetext" href="http://...?nothiddenfield=toto">http://...?nothiddenfield=toto</a> HTTP/1.1[\r][\n]"<br>
<br>
<br>
</small></small></b><small><small><big><big>That is not so weird, I
think, since the button may reference its parent form, does it ?<br>
<br>
Do you see a workaround ? I'm too close to the goal, then I won't
surrender !!!!!!!!!<br>
<br>
Thanks for reading<br>
</big></big></small></small><br>
Marc Guillemot a écrit :
<blockquote cite="mid:4756C395.3070903@yahoo.fr" type="cite">
<pre wrap="">Salut Florent,
to understand what happens, you can try to look at the post details
(url, fields and headers) both in WebTest and in a normal browser for
your 9. step.
</pre>
<blockquote type="cite">
<pre wrap="">...
Is there a way in Webtest to only trigger the Javascript of abutton
without sumitting the form
</pre>
</blockquote>
<pre wrap=""><!---->
you can modify the html DOM to add inject for instance some onsubmit
that returns false in your page, but I don't see what you would achieve
with that.
</pre>
<blockquote type="cite">
<pre wrap="">(I think the navigation error come from the
fact the POST method is not Ajax called ) ?
</pre>
</blockquote>
<pre wrap=""><!---->
???
Marc.
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Pingwy
27, rue des arènes
49100 Angers
</pre>
</body>
</html>
--------------030705090104050205030608--