In order to obtain Cookies object call WebDriver.Cookies.
var cookies = WebDriver.Cookies();
With this object you can read, create and delete cookies.
// Print names of all cookies
var cs = cookies.AllCookies();
for(var i = 0; i < cs.length; i++)
{
// cs[i] contains Cookie object
Tester.Message(cs[i].Name);
}
// Get cookie by name, returns Cookie object
var c = cookies.GetCookieNamed("SESSION");
// Create new cookie
cookies.AddCookie({Name: "MySimpleCookie", Value: "MyValue"});
// Create new cookie for given domain and path
cookies.AddCookie({Name: "MyComplexCookie", Value: "MyValue", Domain: "example.com", Path: "/"});
// Create cookie with expiration
var dt = new Date(); // Construct date-time string in the format "2018-12-30T13:15:00-05:00"
var expDate = UtilGetPaddedZeroesDate(dt) + "T" + UtilGetPaddedZeroesTime(dt) + "-05:00";
cookies.AddCookie({Name: "MyExpiringCookie", Value: "MyValue", Domain: "example.com", Path: "/", Expiry: expDate});
// Delete cookies
cookies.DeleteCookie({Name: "MySimpleCookie", Value: "MyValue"});
cookies.DeleteCookieNamed("MyComplexCookie");
cookies.DeleteAllCookies();
Cookie object in JavaScript has following structure:
{
Name: "CookieName",
Value: "CookieValue",
Domain: "example.com",
Path: "/",
Expiry: "2018-12-28T13:15.00-05:00"
}
Cookies class is described in Rapise documentation.
Check out the sample test on GitHub.