Skip to main content

Cookie handling for selenium webdrivers.

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

selenium_cookies-0.0.4.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

selenium_cookies-0.0.4-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file selenium_cookies-0.0.4.tar.gz.

File metadata

  • Download URL: selenium_cookies-0.0.4.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for selenium_cookies-0.0.4.tar.gz
Algorithm Hash digest
SHA256 fc10926d8d0f2bd5f6d76f8ab18b7c4725583a8f072c16d859b86dd61ddf7163
MD5 9c7952eb3e61a5ca7f610732ea6427ba
BLAKE2b-256 596850a05d8f59f810085db197e1539e0d9cbce4137630ae4b0b8850d8683aba

See more details on using hashes here.

File details

Details for the file selenium_cookies-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: selenium_cookies-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for selenium_cookies-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7413f4f7e89594256efb6894305cd2f1ea8b91f9d2c7bd480ff97f79e22a0e6b
MD5 bec5bd3f25e4a61e1cd3b3f98a8d3f94
BLAKE2b-256 361195cb18fdeafaa6e3b6616a970c847188050d689ebe6524612c88bd5a556d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page