Can I run Selenium ChromeDriver with cookies from actual Chrome installation? Can I run Selenium ChromeDriver with cookies from actual Chrome installation? selenium selenium

Can I run Selenium ChromeDriver with cookies from actual Chrome installation?


Everytime Selenium opens a browser (Chrome/Firefox/IE) it opens a canonical form of that browser. As a tester, you can set browser preferences using DesiredCapabilities object and for chrome you also can use ChromeOptions object, for passing chrome command line arguments.

To choose your profile

ChromeOptions options = new ChromeOptions();options.addArguments("user-data-dir=/path/to/your/custom/profile");

For more on chrome driver capabilities:https://sites.google.com/a/chromium.org/chromedriver/capabilities

For more about user-data-dir command line option for chrome:
https://www.chromium.org/user-experience/user-data-directory


Try this:

from selenium import webdriveroptions = webdriver.ChromeOptions() options.add_argument("user-data-dir=C:\\Path") #Path to your chrome profilew = webdriver.Chrome(executable_path="C:\\Users\\chromedriver.exe", chrome_options=options)

To find path to your chrome profile data you need to type chrome://version/ into address bar . For ex. mine is displayed as C:\Users\pc\AppData\Local\Google\Chrome\User Data\Default, to use it in the script I had to exclude \Default\ so we end up with only C:\Users\pc\AppData\Local\Google\Chrome\User Data.

Source:How to load default profile in chrome using Python Selenium Webdriver?