selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use error with real Chrome Browser
This error message...
selenium.common.exceptions.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
...implies that the --user-data-dir
is already in use.
Your main issue is you have already an open Google Chrome browser session opened for your manual browsing.
There is no such error in your code block. However it seems you are executing program as an Administrator
. But,
A common cause for Chrome to crash during startup is running Chrome as
root
user (administrator
) on Linux. While it is possible to work around this issue by passing--no-sandbox
flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Chrome as a regular user instead.
Solution
Before you execute your test as an user e.g. Administrator, ensure that you don't have any open Chrome browser windows using the same user i.e. Administrator.
Selenium ChromeDriver: unable to set user-data-dir
you need to remove /Default/
because its not valid directory for --user-data-dir
it is for --profile-directory
options.add_argument('--profile-directory=Default')
# or
options.add_argument('--profile-directory=other_profile')
Related Topics
Matplotlib: Specify Format of Floats for Tick Labels
Python Script for Minifying CSS
How to Set the R_Home Environment Variable to the R Home Directory
Create Static Graphics Files (Png, Gif, Jpg) Using Ruby or Python
Dynamic Instantiation from String Name of a Class in Dynamically Imported Module
Python 3.7 Anaconda Environment - Import _Ssl Dll Load Fail Error
Does Python Optimize Modules When They Are Imported Multiple Times
How to Reversibly Store and Load a Pandas Dataframe To/From Disk
What Is the Purpose of _Str_ and _Repr_
How to Change the Styles of Pandas Dataframe Headers
R's Which() and Which.Min() Equivalent in Python
Efficient Ways to Duplicate Array/List in Python
How to Release Memory Used by a Pandas Dataframe
Applying Udfs on Groupeddata in Pyspark (With Functioning Python Example)