K
K
kolomiec_artiom2020-07-06 11:37:00
Python
kolomiec_artiom, 2020-07-06 11:37:00

How to load default profile in Selenium Chrome?

Hello! I'm trying to load the default VK profile in Selenium so as not to pass authorization

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

FILE_NAME_PROFILE = r'C:\Users\user_name\AppData\Local\Google\Chrome\User Data\Profile 2'

options = webdriver.ChromeOptions() 
options.add_argument("user-data-dir=" + FILE_NAME_PROFILE)

driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)
driver.get('https://vk.com')


I created a second profile on purpose so as not to interfere with my current session. But the problem is that this solution does not work for me and Selenium does not see the authorized profile. At the same time, if you specify the path without "Profile 2", then everything works, but authorization occurs through my main profile

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2020-07-06
@kolomiec_artiom

user-data-dir is the folder to save all profiles.
https://chromium.googlesource.com/chromium/src.git...
Specifying the path to the folder - load the default profile named Default.
You can load the desired profile by adding this command to the launch options

options.addArguments("profile-directory=Profile 2")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question