2

I would like seleniumbase to use my existing session when it launches vs starting a clean one.

How do I start selenium using an existing session?

webdriver:

driver = webdriver.Chrome('/snap/bin/chromium.chromedriver', options=option)

UPDATE:

This is marked as a duplicate which it is not.

Dear @TodorMinakov this code here didn't meet my expectations. I wanted whenever I run the python program to select the unique opened window and use selenium over that window. I will appreciate your help. – Youssof H

Same issue here. The referred URL does not grab an existing session.

Michael Mintz
  • 9,007
  • 6
  • 31
  • 48
brad
  • 870
  • 2
  • 13
  • 38

1 Answers1

0

You can use default chrome profile.

options = webdriver.ChromeOptions() 
options.add_argument("user-data-dir=PATH") #)PATH is path to your chrome profile
w = 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,

If path will not work, try to remove \Default\ so we end up with only C:\Users\pc\AppData\Local\Google\Chrome\User Data.

Better to copy-paste default profile outside, because there no way to use same session (cookies) in two browsers in same time.

Ennorath
  • 48
  • 1
  • 7
  • I get an "selenium.common.exceptions.WebDriverException: Message: unknown error: failed to write prefs file" error. – brad Aug 02 '20 at 15:15