Last active
November 11, 2020 17:57
-
-
Save aahnik/7220eac2b1463d6449eff7294bd25349 to your computer and use it in GitHub Desktop.
Using user data dir in selenium. Using a session. Reuse saved cookies. sample_code_selenium_using_user_data_dir.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
session_path = 'path/of/folder/' | |
chrome_driver_path = 'path/of/chrome-driver-executable' | |
url = 'url' | |
chrome_options = Options() | |
chrome_options.add_argument(f'--user-data-dir={session_path}') | |
driver = webdriver.Chrome(options=chrome_options, | |
executable_path=chrome_driver_path) | |
driver.get(url) | |
# manually sign in into google for first time | |
# from the next time use same session_path | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dark mode