Webtest upload file

M

MD

Hello, I am using VS 2005 for Software Testers - I am having trouble
testing the upload of a file (simple text file) to the server. My .NET
code is as follows :-

ASPX:
<input id="filefield1" type="file" name="filefield1" runat="server">
<input type=submit runat=server id=DoUpload value="Upload"
NAME="DoUpload"/>

ASPX.CS:
Protected WithEvents DoUpload As
System.Web.UI.HtmlControls.HtmlInputButton
....
Private Sub DoUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DoUpload.ServerClick

And my webtest is as follows:-

WebTestRequest request12 = new
WebTestRequest("http://vap2.test.group.local/CU1.aspx");
request12.Method = "POST";
request12.QueryStringParameters.Add("class_id", "4", false,
false);
request12.QueryStringParameters.Add("obj_id", "227", false,
false);
FormPostHttpBody request12Body = new FormPostHttpBody();
request12Body.FormPostParameters.Add("__EVENTTARGET",
this.Context["$HIDDEN1.__EVENTTARGET"].ToString());
request12Body.FormPostParameters.Add("__EVENTARGUMENT",
this.Context["$HIDDEN1.__EVENTARGUMENT"].ToString());
request12Body.FormPostParameters.Add("__VIEWSTATE",
this.Context["$HIDDEN1.__VIEWSTATE"].ToString());
request12Body.FormPostParameters.Add("txtDocumentTitle",
"testing2");
request12Body.FormPostParameters.Add(new
FileUploadParameter("filefield1", "c:\\dontneed\\test2.txt"));
request12Body.FormPostParameters.Add("DoUpload", "Upload");
request12Body.FormPostParameters.Add("cmdDone", "Done");
request12.Body = request12Body;
yield return request12;

When I record the webtest all is fine, however when I rerun the
webtest, the resulting page shows "Object moved to here" and a HTTP
status code of 302 (redirected to found page) occurs.

It may have something to do with the button click not being captured as
webtests do not track Javascript. I have tried using Fiddle but to no
avail.

Please can anyone help - I can't find any examples of testing an upload
process via VS2005.

Many thanks
Travis
 
M

MD

I forgot to mention here, the problem is not the 302 - it's the fact
that the file does *not* successfully upload when I play the script
back - has it got to do with the way VS2005 for Software Testers
interpretation of the submit button click's wiring to the ServerClick
event ? Or is there something I have missed - has anyone else out
there successfully tested (via a VS2005 webtest) a file upload ?
Cheers
Travis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top