DEV Community

abbazs
abbazs

Posted on • Edited on

How to launch google-chrome with a specific profile using selenium (python)?

from selenium import webdriver
from selenium.webdriver import ChromeOptions
opts = ChromeOptions()
opts.arguments.append('--profile-directory=Profile 2')
opts.arguments.append(
'--user-data-dir=/home/user_directory/.config/google-chrome/'
)
# In this case the driver is saved in the
# current directory under a folder named driver
driver = webdriver.Chrome(
executable_path="./driver/chromedriver", 
options=opts)
Enter fullscreen mode Exit fullscreen mode

Selenium will throw exception InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir if the argument --user-data-dir is passed with a / at the end of the argument input if the directory already exits, else selenium will not throw exception.

Selenium will still throw an InvalidArgumentException

Top comments (0)