I've a browser(not generated by selenium) which is already logged in to the website.
I need selenium to use the existing cookies so as to not prompt each generated browser for a new login.
here's what i've already tried from what i searched but still can't make it work.
code summary: if the selenium generated browser is already logged in, the browser will close and if it redirected to the login page, it would wait 60 seconds before closing.
import selenium.webdriver.support.ui as ui
import contextlib
import getpass
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
websiteURL = "https://website.alreadylogged.in"
currentUser = getpass.getuser()
chromeOptions = Options()
chromeOptions.add_argument("--user-data-dir=C:\\Users\\" + currentUser + "\\AppData\\Local\\Google\\Chrome\\User Data\\Default")
driver = webdriver.Chrome(executable_path="C:\\Users\\"+currentUser+"\\Documents\\chromedriver.exe",options=chromeOptions)
with contextlib.closing(driver) as chromeDriver:
chromeOptions.add_argument("user-data-dir=C:\\Users\\" + currentUser + "\\AppData\\Local\\Google\\Chrome\\User Data\\Default")
chromeDriver.get(websiteURL)
wait = ui.WebDriverWait(chromeDriver, 60) # timeout after 60 seconds
wait.until(lambda driver: chromeDriver.find_elements_by_class_name(' windows chrome '))