python – How to open Chrome profile in Selenium?

I wrote this simple code using WebDriverManager to make it easier. When the automation is run, the profile selected in the script selects the profile normally, however, any website I put in driver.get does not open.

I have already checked all installations and updates but without success.

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import time

driver_service = Service(ChromeDriverManager().install())
options = webdriver.ChromeOptions()

options.add_argument('--user-data-dir=C:\\Users\\wesle\\AppData\\Local\\Google\\Chrome\\User Data\\')
options.add_argument('--profile-directory=Profile 1')

driver = webdriver.Chrome(service=driver_service, options=options)      
       
driver.get('https://web.whatsapp.com')
time.sleep(3)

[enter image description here](https://i.stack.imgur.com/7YBvt.png)

I’ve already done some research on the internet, but there’s only a solution using the old Chromedriver.

Read more here: Source link