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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for selenium_cookies-0.0.3.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 522fc8d1c28bcc9ec68ffde2900613df9d73e15b4ee50c5c13341400a8a0776d |
|
MD5 | abb450f6a6506aeccff43ccfd5b1fa64 |
|
BLAKE2b-256 | 8e46de42efdf613275a246d5215c99f587aa618cd43ba224ad369fdc636e86ea |
Close
Hashes for selenium_cookies-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5216aaa792f37adf57940dfc15e990992fe70fc1ca3b7e1a7f2f27062fd0cddb |
|
MD5 | 85b1157183a45e0d1a617a3aa4a01d5f |
|
BLAKE2b-256 | b9d13d35484516c634c070d6d1aeb7e3ddd387ae59a950b75a2b5c4193952f75 |