'selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service ./drivers/chromedriver.exe

Trying to set up my first project using Selenium and Python and am getting an error with my chromedriver. I have already found similar questions/solutions on here and have tried implementing their solutions to no success. (adding the path for the chromedriver to my Path environment variables, implementing chrome driver manager, checking the local host line in /etc/hosts) Pls help, I feel lost. I've also tried drivers for alternative browsers, none have worked.

This is the video I am trying to follow, she uses Mac while I am on Windows: https://www.youtube.com/watch?v=6plKL95a134&t=492s

Screenshot



Solution 1:[1]

There are 3 - 4 ways to do it, 1. Directly mentioning the chromedriver.exe path, 2. Adding chromediver.exe to existing python path, 3. Adding chromedriver.exe in the same folder of the python script, 4.Using chromedriver manager, which is good, because you really don't need to add chromedriver.exe anywhere. Use chromedriver as below in your init method -

driver = webdriver.Chrome(executable_path=ChromeDriverManager().install())

you will need below import-

from webdriver_manager.chrome import ChromeDriverManager

and if you have not installed the drivermanager then you can do it using -

pip install webdriver-manager 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1