(Python) Selenium doesn't get the link when i configure my profile

Question:

this is my first question here. i searched a lot in the site to answers, but i don’t get it.
Can anyone please help?

i’m trying to open the chrome with my profile, and it opens correctly, but, the line driver.get("https://google.com") is not executed

i only could get the link if i remove the parameter ‘options=opt’

This is my code:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

opt = Options()
opt.add_argument('user-data-dir=C:\Users\myPC\AppData\Local\Google\Chrome\User Data')
opt.add_argument("profile-directory=Profile 1")
driver = webdriver.Chrome(options=opt)

driver.get("https://google.com")

time.sleep(5)
driver.quit()

tried to add another parameter, as services=ser
tried to use the cookies instead of profile

Asked By: Se77ings

||

Answers:

Pass the profile name(Profile 1) in the path as below:

opt.add_argument("user-data-dir=C:\Users\myPC\AppData\Local\Google\Chrome\User Data\Profile 1")
# opt.add_argument("profile-directory=Profile 1")
Answered By: Shawn