首页 > 解决方案 > 使用 selenium:如何在使用 python 关闭驱动程序后保持登录状态

问题描述

每次我使用 selenium 在 chrome 驱动程序中打开新窗口时都不需要登录 chrome 驱动程序

options = Options()
options.add_argument("user-data-dir=C:\\Users\\oyo\\AppData\\Local\\Google\\Chrome\\User Data")
driver = webdriver.Chrome(chrome_options=options)

driver.get('https://web.whatsapp.com/')
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 10.0.17134 x86_64)

标签: pythonselenium

解决方案


我不知道这样做的方法,除非使用 cookie。

driver.manage().addCookie(arg0)


推荐阅读