To retain cookies and website preferences across sessions, it's necessary to launch Chrome with its default profile when using Python Selenium Webdriver.
The following code provides a solution:
<code class="python">from selenium import webdriver # Set path to default Chrome profile (exclude trailing "\Default") options = webdriver.ChromeOptions() path = "C:\Users\User\AppData\Local\Google\Chrome\User Data" options.add_argument(f"user-data-dir={path}") # Set path tochromedriver.exe w = webdriver.Chrome(executable_path="C:\Users\User\chromedriver.exe", chrome_options=options)</code>
To create and use a separate profile for Selenium:
The above is the detailed content of How to Load the Default Chrome Profile Using Python Selenium Webdriver?. For more information, please follow other related articles on the PHP Chinese website!