Handling session cookies
Websites use cookies to store user preferences, login information, and various other details of the client. The Selenium WebDriver API provides various methods to manage these cookies during testing. Using these methods, we can read cookie values, add cookies, and delete cookies during the test. This can be used to test how the application reacts when cookies are manipulated. The WebDriver.Options
interface provides the following methods to manage cookies:
Method |
Description |
---|---|
|
This method adds a cookie. |
|
This method returns the cookie with a specified name. |
|
This method returns all the cookies for current domain. |
|
This method deletes the cookie with a specified name. |
|
This method deletes a cookie. |
|
This method deletes all the cookies for current domain. |
In this recipe, we will see how to read a cookie and...