'DevToolsActivePort file doesn't exist' error with managed chrome browser or default user directory

Question:

I used to be able to run several instances of Chrome concurrently without issue. After a DevToolsTools active port file doesn’t exist error popped up, the only solution that seemed to get things up and running was options.add_argument('--remote-debugging-port=9222'). However, since I have added that, I can no longer run concurrent or even sequential instances of the automated browser. Running the code below, I will get this error when browser2 tries to start:

(chrome not reachable) (The process started from chrome location
C:Program FilesGoogleChromeApplicationchrome.exe is no longer
running, so ChromeDriver is assuming that Chrome has crashed.)

When I try to start a any browser instance with an existing one running I get the text:

Opening in existing browser session.

Chrome never tried to get into a existing session I added the options.add_argument('--remote-debugging-port=9222') I have tried an multitude of different solutions to the DevToolsTools active port file doesn’t exist issue and this seemed to to be the only one that worked. I’ve also uninstalled and reinstalled chrome.

#selenium modules
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service as ChromiumService
#webdriver manager modules
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.core.utils import ChromeType
#utility modules
from random import randrange

def simple_chrome(page=""):
    options = Options()
    debugging_port = str(randrange(9222, 9999))
    options.add_argument('--remote-debugging-port=%s'%debugging_port)
    service = ChromiumService(ChromeDriverManager().install())
    browser = webdriver.Chrome(service=service, options=options)
    browser.get(page)
    return browser

browser = simple_chrome("https://docs.python.org/3/library/shutil.html")
browser2 = simple_chrome("https://apnews.com")
Asked By: Jack

||

Answers:

I GOT IT!!! I’ve been working this on/off for a few months for a application that I barely use anymore. Thanks for the soundboard.

I had tried launching chrome with --user-data-dir= or --temp-profile per this thread. However, after some great suggestions, I noticed these options would always come up with the same weird profile path

%userprofile%AppDataLocalGoogleChromed_xlincnu

which I checked by typing "chrome://version" in the browser address.

Chrome was always also coming up as ‘managed’ in the the browser settings. So I went to the registry editor and found some weird default profile in HKEY_LOCAL_MACHINESoftwarePoliciesGoogleChrome. I deleted the profile and now it works!

I don’t know how the bogus profile got there. Maybe I was trying some outlandish solution and put it in there and forgot.

Answered By: Jack