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:
- Have the developers of the electron app ensure the "--remote-debugging-port" argument is passed onto Chrome.
- 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 (https://docs.microsoft.com/en-us/sysinternals/downloads/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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…