CookieManager

class splinter.abc.cookie_manager.CookieManagerAPI(driver)[source]

Specification for how a Splinter driver handles cookies.

CookieManager implementations are driver-specific. They should not be created by the end-user. To access a CookieManager, drivers should implement a cookies attribute containing a CookieManager.

CookieManager has behaviour similar to a dict, thus you should get the value of a cookie using the [] operator:

Example

>>> browser.cookies.add({'name': 'Tony'})
>>> assert browser.cookies['name'] == 'Tony'
abstract add(cookie: dict[str, str], **kwargs) None[source]

Add a cookie.

Parameters:
cookie: dict[str, str]

A key/value pair containing the cookie’s name and value.

**kwargs

Driver-specific extra arguments to build the cookie with.

Example

>>> browser.cookies.add({'cookie_name': 'cookie_value'}, path='/')
>>> assert browser.cookies['cookie_name'] == 'cookie_value'
abstract all(verbose: bool = False)[source]

Get all of the cookies.

Note: If you’re using any webdriver and want more info about the cookie, set the verbose parameter to True (in other drivers, it won’t make any difference). In this case, this method will return a list of dicts, each with one cookie’s info.

Example

>>> browser.cookies.add({'name': 'Tony'})
>>> result = browser.cookies.all()
Returns:

All the available cookies.

abstract delete(*cookies: str) None[source]

Delete one or more cookies.

If the cookie does not exist, this function has no effect.

Parameters:
cookies : str

Identifiers for each cookie to delete.

Example

>>> browser.cookies.delete('name', 'birthday', 'favorite_color')
>>> browser.cookies.delete('name')
>>> assert 'name' not in browser.cookies.all().keys()
abstract delete_all() None[source]

Delete all cookies.