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
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