Skip to content

[🐛 Bug]: options --user-data-dir & --profile-directory return: DevToolsActivePort file doesn't exist #15729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BrBriz opened this issue May 10, 2025 · 12 comments
Labels
C-py Python Bindings D-chrome G-chromedriver Requires fixes in ChromeDriver I-defect Something is not working as intended I-regression Something was working but we "fixed" it OS-windows

Comments

@BrBriz
Copy link

BrBriz commented May 10, 2025

Description

Good afternoon! I encountered a problem (after May 2) that when using --user-data-dir & --profile-directory I started getting the error: "DevToolsActivePort file doesn't exist". Since I noticed that Chrome version is 136.0.7103.93, and ChromeDriver version is 136.0.7103.92, I tried using ChromeBeta where both versions were the same (ChromeBeta & ChromeBetaDriver), but it didn't work, just the same error. I tried using: --no-sandbox; --disable-dev-shm-usage; --headless; --remote-debugging-pipe; --remote-debugging-port=9222, but it didn't work, only by removing --user-data-dir and --profile-directory the program worked.
I would be very happy if this problem would be considered and resolved.

selenium_log.txt
selenium_log_with_options.txt

Reproducible Code

from selenium import webdriver
from Utility.System.CloseProcesses import close_name_processes
from selenium.webdriver.chrome.options import Options as Chrome_Options


chrome_driver_path = 'C:\\Users\\bletb\\AppData\\Local\\Google\\Chrome\\User Data'

close_name_processes("chrome")
chrome_options = Chrome_Options()
chrome_options.add_argument(rf"--user-data-dir={chrome_driver_path}")
chrome_options.add_argument(rf"--profile-directory=Default")
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://alerts.in.ua/?pwa")

----
"close_name_processes"
import psutil
from colorama import Fore


def close_name_processes(process_name):
    for process in psutil.process_iter(attrs=["name"]):
        try:
            if process.name() and process_name in process.name().lower():
                process.terminate()
                try:
                    process.wait(timeout=5)
                    print(f"{Fore.BLUE}ℹ️ [close_name_processes]: Closed process: {process.name()}")
                except psutil.TimeoutExpired:
                    process.kill()
                    print(f"{Fore.RED}⚠️ [close_name_processes]: Force killed process: {process.name()}")
        except (psutil.NoSuchProcess, psutil.AccessDenied):
            continue

Debugging Logs

D:\PyCharmProjects\CraftFortress\.venv\Scripts\python.exe "D:\PyCharmProjects\CraftFortress\.test\short test.py" 
ℹ️ [close_name_processes]: Closed process: chrome.exe
ℹ️ [close_name_processes]: Closed process: chrome.exe
ℹ️ [close_name_processes]: Closed process: chrome.exe
ℹ️ [close_name_processes]: Closed process: chrome.exe
ℹ️ [close_name_processes]: Closed process: chrome.exe
ℹ️ [close_name_processes]: Closed process: chrome.exe
ℹ️ [close_name_processes]: Closed process: chrome.exe
ℹ️ [close_name_processes]: Closed process: chrome.exe
ℹ️ [close_name_processes]: Closed process: chrome.exe
Traceback (most recent call last):
  File "D:\PyCharmProjects\CraftFortress\.test\short test.py", line 12, in <module>
    driver = webdriver.Chrome(options=chrome_options)
  File "D:\PyCharmProjects\CraftFortress\.venv\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__
    super().__init__(
    ~~~~~~~~~~~~~~~~^
        browser_name=DesiredCapabilities.CHROME["browserName"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        keep_alive=keep_alive,
        ^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "D:\PyCharmProjects\CraftFortress\.venv\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 67, in __init__
    super().__init__(command_executor=executor, options=options)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\PyCharmProjects\CraftFortress\.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 260, in __init__
    self.start_session(capabilities)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "D:\PyCharmProjects\CraftFortress\.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 357, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\PyCharmProjects\CraftFortress\.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 448, in execute
    self.error_handler.check_response(response)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "D:\PyCharmProjects\CraftFortress\.venv\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: DevToolsActivePort file doesn't exist
Stacktrace:
	GetHandleVerifier [0x00007FF6BDF8CF25+75717]
	GetHandleVerifier [0x00007FF6BDF8CF80+75808]
	(No symbol) [0x00007FF6BDD58F9A]
	(No symbol) [0x00007FF6BDD9B9D9]
	(No symbol) [0x00007FF6BDD96759]
	(No symbol) [0x00007FF6BDD91ADD]
	(No symbol) [0x00007FF6BDDE52D8]
	(No symbol) [0x00007FF6BDDE48B0]
	(No symbol) [0x00007FF6BDDD7153]
	(No symbol) [0x00007FF6BDDA0421]
	(No symbol) [0x00007FF6BDDA11B3]
	GetHandleVerifier [0x00007FF6BE28D6FD+3223453]
	GetHandleVerifier [0x00007FF6BE287CA2+3200322]
	GetHandleVerifier [0x00007FF6BE2A5AD3+3322739]
	GetHandleVerifier [0x00007FF6BDFA69FA+180890]
	GetHandleVerifier [0x00007FF6BDFAE0FF+211359]
	GetHandleVerifier [0x00007FF6BDF95274+109332]
	GetHandleVerifier [0x00007FF6BDF95422+109762]
	GetHandleVerifier [0x00007FF6BDF7BA39+4825]
	BaseThreadInitThunk [0x00007FFFDCB5E8D7+23]
	RtlUserThreadStart [0x00007FFFDE0714FC+44]


Process finished with exit code 1

ℹ️ Last known working version: 4.30

@BrBriz BrBriz added I-defect Something is not working as intended A-needs-triaging A Selenium member will evaluate this soon! labels May 10, 2025
@selenium-ci
Copy link
Member

@BrBriz, thank you for creating this issue. We will troubleshoot it as soon as we can.

Selenium Triage Team: remember to follow the Triage Guide

@github-actions github-actions bot added C-py Python Bindings D-chrome I-regression Something was working but we "fixed" it OS-windows labels May 10, 2025
@cgoldberg
Copy link
Contributor

This works fine for me on Linux with Chrome 136.

Can you verify you have the directory names correct and they actually exist?

C:\\Users\\bletb\\AppData\\Local\\Google\\Chrome\\User Data

This is really confusing. I suggest you remove the double-backslashes and use of raw string, and just use single forward slashes when dealing with Windows paths.

On my machine, there is no User Data directory. Profiles are stored in Default.

Also, try using the full path when specifying --profile-directory.

I don't think there is anything Selenium can fix here.

@cgoldberg cgoldberg added J-awaiting answer Question asked of user; a reply moves it to triage again and removed A-needs-triaging A Selenium member will evaluate this soon! labels May 10, 2025
@BrBriz
Copy link
Author

BrBriz commented May 10, 2025

r'C:\Users\bletb\AppData\Local\Google\Chrome\User Data' did not help (this path exists);
--profile-directory breaks the browser with a full path.
Maybe there are some features of creating DevToolsActivePort? I tried creating a new profile, but that didn't help.
For me this error is very strange because everything was working fine until May 2nd

@cgoldberg
Copy link
Contributor

Is there a file named DevToolsActivePort in that directory?

@cgoldberg cgoldberg added G-chromedriver Requires fixes in ChromeDriver and removed J-awaiting answer Question asked of user; a reply moves it to triage again labels May 10, 2025
@selenium-ci
Copy link
Member

Hi, @BrBriz.
This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team.
Feel free to comment the issues that you raise back in this issue. Thank you.

@BrBriz
Copy link
Author

BrBriz commented May 12, 2025

For those who see this. At the moment the fix is ​​this: download ChromeTest and ChromeDriver of the same version (currently 136.0.7103.92). Then use my code and replace the values ​​with yours:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options as Chrome_Options

# Where ... - username. Also change the path to the browser files; Use url chrome://version/

chrome_user_data = r'C:\Users\...\AppData\Local\Google\Chrome for Testing\User Data'
chrome_driver_path = r'C:\Users\...\Downloads\chromedriver-win64 (2)\chromedriver-win64\chromedriver.exe'
chrome_browser_path = r'C:\Users\...\Downloads\chrome-win64 (1)\chrome-win64\chrome.exe'

service = Service(executable_path=chrome_driver_path)
chrome_options = Chrome_Options()
chrome_options.add_argument(rf"--user-data-dir={chrome_user_data}")
chrome_options.add_argument(rf"--profile-directory=Default")
chrome_options.binary_location = chrome_browser_path
driver = webdriver.Chrome(service=service, options=chrome_options)

driver.get("https://alerts.in.ua/?pwa")

@cgoldberg
Copy link
Contributor

This shouldn't require manually downloading chrome/chromedriver and I don't see how your code is at all helpful.

@BrBriz
Copy link
Author

BrBriz commented May 12, 2025

ChromeDriver 136.0.7103.92 does not work on Windows with Chrome 136.0.7103.93 with --user-data-dir & --profile-directory. This is a manual fix for the bug. I had a person on Discord who had the same problem. My manual solution helped her. This is not an automatic fix, it is just a workaround for the restrictions that Google has put in place (https://developer.chrome.com/blog/remote-debugging-port)

@titusfortner
Copy link
Member

Selenium should be downloading the correct things automatically. If it isn't then we need to figure out why. Hard coding a specific version isn't the right long-term fix.

@BrBriz
Copy link
Author

BrBriz commented May 12, 2025

Titusfortner, I completely agree, but neither you nor I know if Chrome will want to fix this. ChromeTest is just a temporary analogue. I don't want to force anyone to add this code, I just found the reason and told how to avoid it. I don't see the point in arguing on this topic because it's neither your side nor my side of the error.

@titusfortner
Copy link
Member

No, I mean that I think Selenium might currently allow slightly different patch versions of Chrome for Testing and Chromedriver, in which case I think that's a bug and this is a good reason to check to make sure we don't allow that. If Selenium is using CfT it should always exactly match driver version, so I want to know if it isn't doing that.

@cgoldberg
Copy link
Contributor

@BrBriz this is the issue tracker for Selenium development. We are looking to diagnose issues and fix them. If there is a real issue here, it is helpful to know.

I took issue with your wording "the fix is ​​this" ... when what you presented is not at all a fix and shouldn't be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-py Python Bindings D-chrome G-chromedriver Requires fixes in ChromeDriver I-defect Something is not working as intended I-regression Something was working but we "fixed" it OS-windows
Projects
None yet
Development

No branches or pull requests

4 participants