Using Selenium: How to keep logged in after closing the driver in Python

John Doe ·

1135 Views

I tried the below code on my Mac, and it worked perfectly fine. I don't need to login again.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait

chrome_options = Options()
chrome_options.add_experimental_option("detach", True)

chrome_options.add_argument("user-data-dir=/tmp/oriel")
# chrome_options.add_argument("--start-maximized")

browser = webdriver.Chrome(options=chrome_options)
wait = WebDriverWait(browser, 10)

url = "https://oriel.com"
browser.get(url)
browser.implicitly_wait(1)

print(browser.title)

For window you can try changing the path as below

chrome_options.add_argument("user-data-dir=C:\\Users\\Oriel\\AppData\\Local\\Google\\Chrome\\User Data\\Default")

 

Ref.

I want to get my Whatsapp web (web.whatsapp.com) logged in, at the second time opening the Whatsapp web on chrome driver. Following is my code based on Python need your help. from selenium import
GroupsSign inGroupsSelenium UsersConversationsLabelsAboutSend feedbackHelpPrivacy • TermsHow to start ChromeDriver with existing login 11741 viewsChromeJavaSkip to first unread messageTiếu Thủyunread,Nov 26, 2014, 11:59:10 PM11/26/14Reply to auth

 

selenium