Tuesday, 25 August 2009

Working with Cookies and caches Using WATiN 2.0

Release of WATiN 2.0 having work around with cookies and caches like
1. Clear cookies /caches
2. Get and set cookies

1. Clear cookies/caches
This functionality/method we can call any time during the live instance of an IE.
We need to call this method just after creating new instance of an IE.
Example: below code would clear cookies/caches just after creating new instance of an IE.

using(IE ie = new IE())
Caution: if we call this method at later moment then the open instance of an IE still might have cached items in memory. To avoid this situation we need to use new IE.ReOpen() method. This method would close the previous open Instance and reopens new IE instances which solve our problem.

2. Get and set cookies
To manipulate Cookies and/or to read cookie information, IE.GetCookie() and IE.SetCookie are added.
using(IE ie = new IE("http://jawedm.blogspot.com"))
string setvalue = "test-cookie=abc; expires=Wed, 01-Jan-2020 00:00:00 GMT";
ie.SetCookie("http://1.watin.com/", setvalue);
string getvalue = ie.GetCookie("http://1.watin.com/", "test-cookie");
Assert.AreEqual("test-cookie=abc", getvalue);

for more information you can visit below website

1 comment:

Anonymous said...

Hi Everybody!

I've been looking to figure out a place to begin with the Acai Berry free trial & was wanting to know if anybody had any thoughts on whether or not it works for dieting? So far here's the 1 [url=http://acaiberries.zoomblog.com/]article[/url] I have been able to check out that seemed realistic for what my goals are. Opinions?