I want my program to open up the default chrome profile and then get youtube. I can make it either open youtube (in a new chrome browser), or open the default chrome profile, but not both. (And no im not running both driver variables)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
print('starting')
print('getting driver')
exec_path= "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" # exec path from chrome://version
profilePath= 'C:\Users\MyName\AppData\Local\Google\Chrome\User Data\Profile 1' #profile path from chrome://version
chromePath= 'C:\Users\MyName\OneDrive\Documents\Python programming\chromedriver.exe' #path to driver
options= webdriver.ChromeOptions()
options.add_argument(profilePath)
print('options add argument...')
### Run one or the other ###
driver = webdriver.Chrome(executable_path= chromePath , options=options) #gets youtube
driver = webdriver.Chrome(executable_path= exec_path, options=options) #gets chrome profile
print('webdriver getting youtube...')
driver.get("https://www.youtube.com/")
when I run the driver line that gets the chrome profile I get the error:
Traceback (most recent call last): File "C:UsersMyNameOneDriveDocumentsPython programmingWeb automationwebAuto.py", line 24, in driver = webdriver.Chrome(executable_path= exec_path, options=options) #gets chrome profile File "C:UsersMyNameAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverchromewebdriver.py", line 73, in init self.service.start() File "C:UsersMyNameAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdrivercommonservice.py", line 104, in start raise WebDriverException("Can not connect to the Service %s" % self.path) selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service C:Program Files (x86)GoogleChromeApplicationchrome.exe
question from:https://stackoverflow.com/questions/65863395/chromedriver-wont-get-website-python-selenium