Wednesday, November 12, 2014


A cookie is a small file stored on the client computer by the server. If the user requests a web page then the server uses cookie information to identify the user. With selenium, you can create, get and delete cookies.

1. Create cookie - There are several ways to create cookie.

         a) Cookie name = new Cookie("cookieName", "cookieValue");
             driver.manage().addCookie(Cookie arg0);


Click here for example.





2. Get cookies data - There are several ways to get cookie.

         a) driver.manage().getCookies();
         b) driver.manage().getCookieNamed(String arg0);


Click here for example.


3. Delete cookie - There are several ways to delete cookie.

         a) driver.manage().deleteCookieNamed("String arg0");
         b) driver.manage().deleteCookie(Cookie arg0);
         c) driver.manage().deleteAllCookies();


Click here for example.