selenium - Showing Error - unknown error: DevToolsActivePort file doesn't exist - it's electron application (I am using windows OS)) - TagMerge
5Showing Error - unknown error: DevToolsActivePort file doesn't exist - it's electron application (I am using windows OS))Showing Error - unknown error: DevToolsActivePort file doesn't exist - it's electron application (I am using windows OS))

Showing Error - unknown error: DevToolsActivePort file doesn't exist - it's electron application (I am using windows OS))

Asked 1 years ago
5 answers

I have been experiencing the error DevToolsActivePort file doesn't exist myself and in my case the error was correct and the root cause was the electron app itself.

Since v2.39 Chrome's web driver (chromedriver.exe) by default looks for a file named DevToolsActivePort and when found reads it to obtain the port number of devtools that is currently running in chrome (and in your case the Chrome instance that the electron app "angular-electron 0.1.0.exe" is running).

When you create a ChromeDriver in Selenium and include the --remote-debugging-port=0 argument, or otherwise do not include this argument at all, then chromedriver will send --remote-debugging-port=0 in the command line to your electron app (ie. angular-electron 0.1.0.exe). If your electon app passes this argument onto the Chrome app running inside it then the DevToolsActivePort file is created, chromedriver can read it and gain the port of devtools, and automation is successful. However if your electron app does not pass this argument to Chrome then the DevToolsActivePort file is never created and your chromedriver times out looking for it and fails.

You have a couple of options for a solution:

  1. Have the developers of the electron app ensure the "--remote-debugging-port" argument is passed onto Chrome.
  2. Automate your own solution for creating the "DevToolsActivePort" file.

In my case I went with option 2. Here's how you can test this option manually. If you run an application like SysInternal's Tcpview ( before your electron app then Tcpview will show you the ports that your electron app is listening on. One of these ports will be the Chrome's devtools port. Note this down. Now go into your %temp% folder in Windows as this is the default location for the temporary folder containing the DevToolsActivePort file that chromedriver is looking for. In this folder look for the folders prefixed with scoped_dir. By default chromedriver will create one these each time you run it. To guarantee you access the correct folder it's best to set this directory name yourself beforehand in chromedriver using the --user-data-dir argument before running it. Go into this folder and create a new file named DevToolsActivePort and enter the port number on the first line, press Enter (newline), and then any number on the second line. Save the file and close. If you complete this entire process manually within 60 seconds the running chromedriver will read that file, get the port of Chrome's devtools, connect to it and continue.

I have developed an AutoIT script that does the above process automatically and I include this in my own automation runs and works every time.

Hope this helps.

Source: link


This error message...

org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist. 
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z' 
System info: host: 'DESKTOP-GN8LLQU', ip: '', 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.2' 
Driver info: driver.version: ChromeDriver

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

Your main issue is the incompatibility between the version of the binaries you are using as follows:

  • Possibly you are using the latest chromedriver=77.0
  • Possibly you are using_chrome= 77.0_
  • Your Selenium Client version is 3.6.0 of 2017-09-27T15:28:36.4Z which is almost 2 years older.
  • Your JDK version is 11.0.2.

So there is a clear mismatch between the Selenium Client v3.6.0 , ChromeDriver v77.0 and the Chrome Browser v77.0


Ensure that:

  • Selenium is upgraded to current levels Version 3.141.59.
  • ChromeDriver is updated to current ChromeDriver v77.0 level.
  • Chrome is updated to current Chrome Version 77.0 level. (as per ChromeDriver v77.0 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test as non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Note: As per Unable to import org.openqa.selenium.WebDriver using Selenium and Java 11 it may be a better idea to downgrade to Java 8


Source: link


Although this is an old question but want to add my answer here, it may help someone. My environment was [ When I can see the same error ] :

  1. Windows 10
  2. Selenium 3.14
  3. Chrome driver 85.0.4183.87
  4. Browser version for electron app is 85.0.4183.121

[ Sidenote : I am trying to automate Microsoft Teams and it is an electron app ] .

After searching a lot through internet came to conclusion that it is somehow a version mismatch . Finally this github issue link backed my theory and the ChromeDriver 2.37.544315 attached in its answer worked for me.

My code is similar to what we see in the SO question.

     System.setProperty("", "C:\\chromedriver\\chromedriver.exe");
     ChromeOptions opt = new ChromeOptions();
     WebDriver driver = new ChromeDriver(opt);

and output is [ As expected : Teams opens up without any error ]:

Starting ChromeDriver 2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7) on port 2389
Only local connections are allowed.
Jan 12, 2022 1:23:57 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

Source: link


I have the following code
from selenium import webdriver
from import Options

options = Options()
driver = webdriver.Chrome(options=options)
which returns the error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/", line 81, in __init__
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/", line 321, in execute
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Source: link


Added the below code to invoke the chrome
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);
WebDriver driver = new ChromeDriver(options);

Source: link

Recent Questions on selenium

    Programming Languages