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

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay