Saturday, December 20, 2008

Quick way to fix missing dynamic parameters in VSTS Web Test

Recording and playing back web tests which involve private users sessions, VSTS Web test misses some parameters including cookies. Since these cookies from the responses are not recorded and not sent in the future requests, the web tests fail.

Solution:
Subclass the WebTestPlugin class in namespace Microsoft.VisualStudio.TestTools.WebTesting and register to handle the PreRequest and PostRequest events.

In the PostRequest event, if the args.Response contains cookies, get and store it in a variable.
In the PreRequest event, add the cookies from the variable to the args.Request object.

No comments:

Post a Comment