Cookies

It is possible to manipulate cookies using the cookies attribute from a Browser instance.

browser.cookies.add({'chocolate_chip': '200'})

Extra Arguments

Each driver accepts various parameters when creating cookies. These can be used with browser.cookies.add as extra arguments. For example, WebDriver can use path, domain, secure, and expiry:

browser.cookies.add({'chocolate_chip': '200'}, path='/cookiePath')

Retrieve all cookies

cookies = browser.cookies.all()

Given a cookie named chocolate_chip, we can delete it by passing the name to the delete method:

browser.cookies.delete('chocolate_chip')

Multiple cookie names can be passed to delete:

browser.cookies.delete('chocolate_chip', 'blueberry')

Delete all cookies

browser.cookies.delete_all()

Further Reading

For more details see the API reference for the CookieManager class.