Closed
Description
What happened?
I am trying to launch a headless Chrome WebDriver using Selenium in Python. However, I keep encountering this error:
How can we reproduce the issue?
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
def createModel():
service = Service(ChromeDriverManager().install())
options = webdriver.ChromeOptions()
# Specifying user data directory
options.add_argument("--user-data-dir=/root/video-downloader/tmp/selenium-user-data")
options.add_argument("--headless=new")
options.add_argument("--start-maximized")
driver = webdriver.Chrome(service=service, options=options)
return driver
driver = createModel()
driver.get("https://www.google.com")
print(driver.title)
driver.quit()
Relevant log output
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: probably user data directory is already in use,
please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
Operating System
Ubuntu
Selenium version
4.29.0
What are the browser(s) and version(s) where you see this issue?
Chrome
What are the browser driver(s) and version(s) where you see this issue?
Google Chrome 133.0.6943.126 ChromeDriver stable(auto)
Are you using Selenium Grid?
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
github-actions commentedon Feb 24, 2025
@ammarft-ai, thank you for creating this issue. We will troubleshoot it as soon as we can.
Info for maintainers
Triage this issue by using labels.
If information is missing, add a helpful comment and then
I-issue-template
label.If the issue is a question, add the
I-question
label.If the issue is valid but there is no time to troubleshoot it, consider adding the
help wanted
label.If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable
G-*
label, and it will provide the correct link and auto-close the issue.After troubleshooting the issue, please add the
R-awaiting answer
label.Thank you!
diemol commentedon Feb 24, 2025
I am not sure how we can help. You need to make sure the profile is not being used.
cgoldberg commentedon Feb 25, 2025
This could be caused by trying to access a profile that's already in use, or if the profile is not readable/writeable (yours seems to be owned by root?)
Either way, the error message is coming from chromedriver, so I don't think there is anything to fix from the selenium side.
kiyotsu commentedon Feb 25, 2025
It also occurs in my environment.
I am running my tool with administrator privileges.
This error does not occur except when running as administrator.
I assume that an Edge version update triggers this error.
OS:Windows10
language:c#
thepbnk commentedon Feb 25, 2025
I don't know the cause, but I avoided the error by running msedgedriver.exe before initializing the driver.
cgoldberg commentedon Feb 26, 2025
Try running
chromdriver.exe
from the command line, passing it the--user-data-dir
argument and supplying the location of your profile. That will verify this is an issue with ChromeDriver and not selenium.However, since the error is coming from ChromeDriver... this doesn't look like a selenium issue and it should reported to the ChromeDriver devs.
cgoldberg commentedon Feb 26, 2025
@thepbnk
Why are you running as Admin?
Also, the reported issue was for Chrome, not Edge.
thepbnk commentedon Feb 26, 2025
@cgoldberg
Running it with administrator rights was a method I found while looking for a way to reproduce the error.
The PC where the error occurred did not have administrator rights, but it did occur. And I was able to avoid the error with this method.
Although it is a Chrome issue, I thought that a similar method could be used, so I left a comment.
VietND96 commentedon Feb 26, 2025
If running as admin (in Windows) or with sudo (in Linux), can you try to pass browser arg
--no-sandbox
to see any help?Refer to https://stackoverflow.com/a/70385974/14532601, #14609 (comment)
39 remaining items
VietND96 commentedon Mar 6, 2025
@niceguy4, I saw your comment mentioned the issue when you ran test in the container, and fix by installing missing deps via
apt install
. I am not sure the browser pre-configure, but looks like you are usingchrome-linux64.zip
fromchrome-for-testing
, in package there is a filedeb.deps
with mention all deps needed for chrome can be launched, I think you can refer to that to keep container env install enough deps.ssada1975 commentedon Mar 6, 2025
Same issue but it occurred when upgrading from 131 to upper version With the same parameters to launch cromedriver.
Isn't there any way to check what changed between 131 And 132 for example in chrome driver to find the solution ?
cgoldberg commentedon Mar 6, 2025
@ssada1975
You'll have to take that up with chrome/chromedriver maintainers.
thos-grol commentedon Mar 7, 2025
I was using admin. But with that option it now works even though I am using it.
In my past runs I was also using it too, so whatever change the edge driver creators made broke stuff.
niceguy4 commentedon Mar 7, 2025
@VietND96 Thank you!
medsagou commentedon Mar 9, 2025
If you are using ubuntu bash, u have to run this commend before runing a selenium program
sudo apt install -y libxss1 libappindicator3-1 libindicator7
and add the folwoing arguments if you are using and ubuntu rdp:
options.add_argument("--no-sandbox") options.add_argument("--disable-dev-shm-usage")
titusfortner commentedon Mar 20, 2025
For what it's worth I was also getting this recently with a new job I was running on GitHub Actions.
I fixed it by enabling this step to set xvfb and fluxbox: https://github.com/SeleniumHQ/selenium/blob/ffbfa024/.github/workflows/bazel.yml#L142-L148
Since this is not an issue that can be addressed by making changes in Selenium codebase, I'm going to close it. Thanks everyone for reporting and providing help. I'll include links below for getting additional help.
github-actions commentedon Mar 20, 2025
๐ฌ Please ask questions at:
hafiz031 commentedon Apr 8, 2025
Also, make sure
chromedriver
is installed:chromedriver --version
If not install with:
apt install chromium-chromedriver