How to handle cookies in the Selenium web driver using Python
Selenium is a Python automation module used to automate and test web applications. In this answer, we’ll learn to handle cookies in Selenium using Python.
Cookies are files that contain small pieces of data sent by the server to the web browser. We can store, retrieve, delete, and list cookies using the below methods:
-
add_cookie()
: We can add a cookie using this method. -
get_cookies()
: It is used to list all cookies. -
get_cookie()
: It is used to get only one cookie based on its name. -
delete_cookie()
: It is used to delete a cookie based on its name. -
delete_all_cookies()
: It is used to delete all the cookies.
Code example
Let’s look at the example below:
Read more here: Source link