Using Selenium 4, I am trying to load up my personal browser profile (including cookies), so that it can load into the websites I have previously logged in to. I am using the edge browser. When testing my code snippet, it does not seem to load my browser profile, instead creating a new one (profile 1). I've ensured that the path to the profile is the correct one.
My code snippet:
edge_options = webdriver.EdgeOptions()
edge_options.use_chromium = True
edge_options.add_argument("no-sandbox")
edge_options.add_argument("disable-dev-shm-usage")
edge_options.add_argument("disable-features=LockProfileCookieDatabase")
edge_options.add_argument("user-data-dir=C:\\Users\\Username\\AppData\\Local\\Microsoft\\Edge\\User Data\\Default")
driver = webdriver.Edge(options=edge_options)
targeturl = 'https://www.targeturl.com/'
driver.get(targeturl)
I was expecting it to load my browser profile and then visit the target url, which should be behind a login, to confirm that it does load the cookies too.
Is there something I am missing?
user-data-dir
argument, you could try setting theprofile-directory
argument, which would be the name of your profile and not the full path (and thus you shorten youruser-data-dir
up until "User Data"). I don't know if this will help.