Skip to main content

Selenium Cookie Handler

What does it do?

Saves and loads cookies from a given selenium webdriver.

Why?

Useful for storing user information amongst other things. This is actually ripped from my myNotifsV2 project where I save & load cookies in order to automatically log the user in rather than having them log in every single time they run the application.

Installation

pip install selenium_cookies

Usage

from selenium import webdriver
from selenium_cookies import CookieHandler
dummy_driver = webdriver.Firefox()
#   The second argument is the page to go to when saving/loading cookies.
#   In some cases this is necessary for the loading and saving of cookies
#   to actually work. If you don't have this issue, you can just set it to None.
cookie_handler = CookieHandler(dummy_driver,"https://github.com/adamhb123/selenium_cookies", 
                               overwrite=False, filename="cooks", wait_time=5)
#   save_cookies() saves the site cookies to the specified file
saved_cookies = cookie_handler.save_cookies()
#   load_cookies() loads the saved cookies from the given file (or from the most recently saved one)
loaded_cookies = cookie_handler.load_cookies()
print("Saved cookies == loaded cookies == cookie_handler.loaded_cookies: " + str(
        saved_cookies == loaded_cookies == cookie_handler.loaded_cookies))

Should you so choose, there is also a basic test available in selenium_cookies.tests:

from selenium import webdriver
from selenium_cookies.tests import test_module
dummy_driver = webdriver.Firefox() # could also be webdriver.Chrome()
#   If the driver argument is not supplied, test_module.test attempts to create
#   the webdriver.Firefox instance with the locally stored geckodriver (0.27.0).  
test_module.test(driver=dummy_driver)

Metadata

Release files for selenium-cookies 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for selenium-cookies 0.0.4
File Size Uploaded
selenium_cookies-0.0.4.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for selenium-cookies 0.0.4
File Interpreter ABI Platform
selenium_cookies-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / selenium_cookies-0.0.4.tar.gz

Download URL selenium_cookies-0.0.4.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fc10926d8d0f2bd5f6d76f8ab18b7c4725583a8f072c16d859b86dd61ddf7163
BLAKE2b-256 checksum
How to use checksums
596850a05d8f59f810085db197e1539e0d9cbce4137630ae4b0b8850d8683aba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.2

Release files / selenium_cookies-0.0.4-py3-none-any.whl

Download URL selenium_cookies-0.0.4-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7413f4f7e89594256efb6894305cd2f1ea8b91f9d2c7bd480ff97f79e22a0e6b
BLAKE2b-256 checksum
How to use checksums
361195cb18fdeafaa6e3b6616a970c847188050d689ebe6524612c88bd5a556d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page