0

I've seen the DevToolsActivePort error come up in a couple of StackOverflow posts, but not of the fixes for those have worked for me. I'm using a Chromium browser (as opposed to Google Chrome), so that might be where I'm running into issues?

This is my code:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--headless')
... # plus other options, but the above 3 seem to have solved the issue for other users
options.binary_location = '/usr/bin/chromium-browser'
driver = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install(),chrome_options=options)

I'm using ChromeDriverManager to avoid problems with chromedriver version compatibility.

This gives the error selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist.

Any pointers on what might be causing the issue are appreciated.

sngoh
  • 56
  • 5

3 Answers3

0

Have you seen the answer at https://stackoverflow.com/a/56638103/12570861 ?

Try adding the argument --remote-debugging-port=<port>

0

I was getting this error after upgrading my chromedriver version to 86 and Python runtime to 3.8 from 3.6 on AWS Lambda (Amazon Linux 2) run in a docker container. I played whack a mole for hours with chrome/chromedriver starting issues.

Eventually I found this actively maintained min miplementation of python+selenium+docker. https://github.com/umihico/docker-selenium-lambda/ The setup in their Dockerfile and test.py chrome_options worked.

Kyle
  • 321
  • 1
  • 14
0

I was stuck on this issue for about 2 days reading through and trying all of the posted threads regarding including the above. First, I thought it was some new code I had added but when I re-tried some code that had worked before it now had this issue too. After re-reading WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser I decided to check the chromedriver version in my virtual environment

chromedriver -v

and I found that I didn't have chromedriver install in the virtual environment. So, I installed it using

apt install chromium-chromedriver -y

Now it is working again without this error and no extra added options

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--no-sandbox")
driver = webdriver.Chrome(options=chrome_options)
Ricky S
  • 9
  • 3