How to use existing session with Seleniumbase?
Question:
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.
Answers:
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:UserspcAppDataLocalGoogleChromeUser DataDefault,
If path will not work, try to remove Default so we end up with only C:UserspcAppDataLocalGoogleChromeUser Data.
Better to copy-paste default profile outside, because there no way to use same session (cookies) in two browsers in same time.
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.
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:UserspcAppDataLocalGoogleChromeUser DataDefault,
If path will not work, try to remove Default so we end up with only C:UserspcAppDataLocalGoogleChromeUser Data.
Better to copy-paste default profile outside, because there no way to use same session (cookies) in two browsers in same time.