Chromedriver Devtools Port Number Error

Chromedriver Devtools port number error

Had the same problem, I had to upgrade Chrome to the latest release and it fixed it.

WebDriverException: Message: unknown error: Could not remove old devtools port file error updating the Selenium Options() within a function

This error message...

selenium.common.exceptions.WebDriverException: Message: unknown error: Could not remove old devtools port file. Perhaps the given user-data-dir at "C:\Users\ResetStoreX\AppData\Local\Google\Chrome\User Data" is still attached to a running Chrome or Chromium process

...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session for either of the following reasons:

  • There are previous instance of ChromeDriver process attached to the system memory.
  • You have a manually opened google-chrome session already running.

Because as per RemoveOldDevToolsActivePortFile():

Status RemoveOldDevToolsActivePortFile(const base::FilePath& user_data_dir) {
base::FilePath port_filepath = user_data_dir.Append(kDevToolsActivePort);
// Note that calling DeleteFile on a path that doesn't exist returns True.
if (base::DeleteFile(port_filepath)) {
return Status(kOk);
}
return Status(
kUnknownError,
base::StringPrintf(
"Could not remove old devtools port file. Perhaps the given "
"user-data-dir at %s is still attached to a running %s or "
"Chromium process",
user_data_dir.AsUTF8Unsafe().c_str(), kBrowserShortName));
}


References

You can find a couple of relevant detailed discussions in:

  • chromedriver.exe runs ~8 chrome.exe instances
  • Many process of Google Chrome (32 bit)

Chrome Driver - no longer able to use DevTools api of a web driver session opened by selenium

You no longer need to use chrome-remote-interface to access the chrome debugging port. You can now use Selenium 4's new ChromeDriver dev tools SDK to execute commands against chrome through the CDP.

Switching to this fixed the problem.

WebDriverException: Message: unknown error: DevTools returned unknown type:service_worker

This looks most probably like a ChromeDriver Issue.

You can try with downloading the latest Chrome WebDriver here

for you Platform or operating system.

It should work.



Related Topics



Leave a reply



Submit