How Selenium manipulate cookies using Java?

How Selenium manipulate cookies using Java?

Hi Devan,

Selenium provides functions to capture, manipulate and set cookies. You can interact and query Selenium cookies using the following:

  • .getCookies() – This method is used to return the list of all cookies
  • .getCookieNamed(“cookie name”) – This method returns cookie based on its name
  • .addCookie(“cookie”) – This method creates and adds a cookie
  • .deleteCookie(“cookie”) – This method deletes a cookie
  • .deleteCookieName(“cookie name”) – This method deletes cookie based on its name
  • .deleteAllCookies – This method delete all the cookies

In order to get into details of handling cookies in Selenium WebDriver, plz go through the following blog:

2 Likes