[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. 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
  2. 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
  3. A SIM card is a prepaid cellular telecommunications service that allows a mobile phone to connect to a mobile network. A SIM card is inserted into a mobile phone. SIM cards come in various sizes, shapes, and colors and are sold in various markets. SIM cards are also available as a prepaid service. A prepaid SIM card allows the user to make calls, send text messages, and access the internet without having to pay for minutes or data usage. International SIM Card

    ReplyDelete

Post a Comment