DEV Community

abbazs
abbazs

Posted on • Edited on

6 3

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

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more