[Solved] Error: DevToolsActivePort file doesn't exist


Hello friends, I was running a web scraper in python and I recieved this error

1
WebDriverException: unknown error: DevToolsActivePort file doesn’t exist

I was trying to create a webdriver.Chrome() instance by using the following code

1
2
from selenium import webdriver
driver = webdriver.Chrome()

Then I searched on internet about it, added Selenium to $PATH variable, tried to run it in –no-sandbox mode, and lots of other things but with no success.
But, finally after extensive research on this topic I found the correct way to implement it.
I will start from the start
1. Install pip

1
sudo apt install python3-pip

2. Install Selenium

1
pip install selenium

3. Install Chromium

1
sudo apt-get install chromium-browser

4. Copy the path of Chromium, in my case it was:

1
/usr/bin/chromium-browser

5. Implement this code in python

1
2
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

1
2
options.binary_location = "/usr/bin/chromium-browser"
driver = webdriver.Chrome(chrome_options=options)

And now, you won’t get the error on executing your python code!
You can also add below options according to your needs:

1
2
3
4
5
6
7
8
9
10
11
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
options.addArguments("test-type");
options.addArguments("start-maximized");
options.addArguments("--window-size=1920,1080");
options.addArguments("--enable-precise-memory-info");
options.addArguments("--disable-popup-blocking");
options.addArguments("--disable-default-apps");
options.addArguments("test-type=browser");
options.AddArgument("--incognito");
options.AddArgument("--no-sandbox");

Thanks for reading! Happy Coding :)
Buy Me a Coffee - https://www.buymeacoffee.com/agautam

Comments

  1. Thanks for sharing this information. This is really useful. Keep doing more.
    Hire Java Developers

    ReplyDelete
  2. Your blog took to me an entirely significant spot. It is a beneficial and factual article to enhance knowledge. Thanks for sharing an article like this.Vps Hosting Saudi Arabia

    ReplyDelete
  3. You have made my day by sharing such great post about week calendar. Thanks for posting such an informative post. Keep it up. business phone providersSend invitation through text or email.

    ReplyDelete
  4. It's a nice article, Which you have shared here about the Your article is very informative and I really liked the way you expressed your views in this post. Thank you.Softphone UAE

    ReplyDelete

Post a Comment