While VS2008 has a CookieContainer that is a container for cookies, there is not a .Clear() method to clear out all the cookies like can be done with LoadRunner with the web_cleanup_cookies() API call.
I have found the way to do this is to use assign a new CookieContainer during the PreWebTest event to clear out all pre-existing cookies like this:
1: public Some_Coded_Web_Test() {
2: this.PreAuthenticate = true;
3: this.PreWebTest += new EventHandler<PreWebTestEventArgs>(ClearCookies);
4: }
5:
6: void ClearCookies(object sender, PreWebTestEventArgs e) {
7: Debug.WriteLine("Ha!Ha! I am clearing cookies!");
8: this.Context.CookieContainer = new System.Net.CookieContainer();
9: }
No more tasty, tasty cookies on script iterations.
No comments:
Post a Comment