
Introduction
This article explains the working of an application/utility that enables
Microsoft ACT test ASP.Net applications.
Background (optional)
Microsoft Application Center Test (ACT) is quite simple and a nice tool to test
the web applications' performance. It lets the user record a session and then
through vbscript generation it enables the user test the application
simulating the real world environment (controlling number of users, concurrent
sessions etc). But for ASP.Net applications, there is a problem with ACT
ver 1.0 that it does not support ASP.Net applications because primarily
ACT was developed for ASP/generic html applications and it lacks the
functionality to handle the ASP.Net viewstate. Nevertheless, there is a
workaround that makes it possible using ACT for ASP.Net application testing but
it requires manual editing of the vbscript code. This article describes a
utility that automates the task of manual editing and make it simple for the
developers/testers to modify the ACT vbscript code. Users just need to copy the
ACT generated code into the ACT.Net conversion utility application and it gives
back the code that can be used in Microsoft ACT to test the ASP.Net
application.
Using the code
Well, basically you won't need to do much with the code, you can simply
download the demo application and use it to convert the vbscript code to make
it support ASP.Net application testing.
Following are the steps to follow in order to use the demo app.
Instructions:
1. Record a test in Microsoft ACT.
2. Copy the vbscript from the ACT recorded Test.
3. Paste the text in the "Source"text field in ACT.Net Conversion utility
4. Press Convert
5. Once it shows complete, click on "Output"
6. Copy the script and then paste it back to the ACT test. (Alternatively you
can create a new blank test and paste it).
7. There is a limitation in Microsoft ACT, it doesn't allow you paste very
large scripts. To overcome this problem, access the {testname}.vbs file (in
your ACT project folder) through your browser and open in notepad/wordpad.
Paste the new script and then save it. Reload the project in Microsoft ACT.
8. Run the test!.
9. There is a possibility that you may get some errors with the function
Mid(..,..). It happens when the viewstate size is very large. To resolve this
issue, repeat steps 3-7 with an increased buffer size (300000 or more).
For those who are interested in the code (or may like to make some of thier own
changes to the generated code) here I explain how the application works
The code is pretty simple to understand. What it does that it updates the
vbscript code generated by Microsoft ACT by inserting variable declarations,
setting the request/response buffer size to hold the entire viewstate, storing
the viewstate data in a variable and in the next request appending that data,
stored in the variable, to the request object.
System.String searchCode = "strStatusCode = oResponse.ResultCode";
System.String searchCode2 = "Set oResponse = oConnection.Send(oRequest)";
System.String manualCode2 = "oRequest.ResponseBufferSize = "+this.txtBuffer.Text +Environment.NewLine+" Set oResponse = oConnection.Send(oRequest)";
System.String searchCode3 = "fEnableDelays = False";
System.String manualCode3 = "fEnableDelays = False "+Environment.NewLine+"Dim strViewState "+Environment.NewLine+"Dim Pos1, Pos2 ";
manualCode.Append(" strStatusCode = oResponse.ResultCode "+Environment.NewLine+" ' Manual Code injection- begin"+Environment.NewLine);
manualCode.Append(" If InStr(oResponse.Body, \"__VIEWSTATE\") Then"+Environment.NewLine);
manualCode.Append(" Pos1 = InStr(InStr(oResponse.Body, \"__VIEWSTATE\"), oResponse.Body, \"value=\")"+Environment.NewLine);
manualCode.Append(" Pos2 = InStr(Pos1, oResponse.Body, \">\")"+Environment.NewLine);
manualCode.Append(" strViewState = Mid(oResponse.Body, Pos1 + 7, Pos2 - Pos1 - 10)"+Environment.NewLine);
manualCode.Append(" ' Manually encode viewstates:"+Environment.NewLine);
manualCode.Append(" ' Replace all occurrences of \"+\" with \"%2B\""+Environment.NewLine);
manualCode.Append(" strViewState = Replace(strViewState, \"+\", \"%2B\")"+Environment.NewLine);
manualCode.Append(" ' Replace all occurrences of \"=\" with \"%3D\""+Environment.NewLine);
manualCode.Append(" strViewState = Replace(strViewState, \"=\", \"%3D\")"+Environment.NewLine);
manualCode.Append(" End If"+Environment.NewLine);
manualCode.Append(" ' Manual Code injection- end\""+Environment.NewLine);
modifiedCode.Append(this.txtSource.Text);
Finally do the insertion/replacements
modifiedCode.Replace(searchCode3, manualCode3);
modifiedCode.Replace(searchCode2, manualCode2);
modifiedCode.Replace(searchCode, manualCode.ToString());
History
Initial: 06/06/06. Hassan Syed
Last updated on : 07/06/06. Hassan Syed