VSTS 2008, Web Tests and using Fiddler
I am happy to report that things are much better in this version, but still not as easy as I had hoped. Form value extraction and recognition of AJAX requests seem to work well.
However, I still had some problems running the tests. For the most part they would run ok, but would cause errors on the server such as:
'Index was outside the bounds of the array.' at System.Web.Handlers.ScriptResourceHandler.ProcessRequest
which was always when accessing some script resource via the ScriptResource.axd handler.
I could see no reference to any of my code in there. Everything seemed to work as far as the client aspect was concerned (examining the results of the web tests) but this did not sit too well with me.
So I decided to try and record some tests via Fiddler2 HTTP proxy tool to see if that helped. There was definitely a little more work in getting this to record and playback web tests properly, but I was able to get some cleaner looking tests, and no errors generated on the server using this method. I did verify that all the functionality was being exercised on the server just in case I was missing anything and getting false positives.
The procedure I used to record web tests and get them working was.
- Load Fiddler2
- Load Internet Explorer and browse to the site, running through my specific performance test scenario.
- In Fiddler, press F12 to ensure no more sessions/traffic is captured.
- Select all the sessions by using CTRL-A (ensuing there was no other traffic that got recorded at the time. If there was, just highlight that session and delete it)
- Go to the File >> Save >> Sessions >> As Visual Studio Web Test menu option
- In Visual Studio 2008, within your test project, add in the existing web test.
- VS2008 will add some 'Form Field' extraction rules to each request.
- If you are using UpdatePanel's a lot and need to extract the ViewState from UpdatePanel delta responses, you will need to change the extraction rule.
- For this I created a Text Extraction rule.
- This rule simply looks for __VIEWSTATE| (yes, that's a pipe char on the end) as the start text and a pipe | as the end delimiter text and extracts everything in between.
- I had to add this extraction rule to each request, and replace the references to the old Form field extraction value
- with references to our new AJAX text extraction rule.
Like I said, it was a little bit of work to go through each page request and fix it in this manner, but the tests execute cleanly every time with no errors on the server as previously mentioned and it is actually a neater looking web test.