when i run my script , i got this error
Traceback (most recent call last):
File \"C:\\Users\\ishaq\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-
I had the same error in Linux. The fix is pretty simple. Just run this command and the error will go away.
sudo apt install chromium-chromedriver
If we analyze the logs it seems the main issue is with in start os.path.basename(self.path)
and subsequent error message selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
.
So it's clear from the error that the Python client was unable to locate the chromedriver
binary.
You have to take care of a couple of points here:
chrome_options.binary_location
: The parameter configures the chrome.exe
not the chromedriver.exe
os.path.abspath("chromedriver")
will pick up the file path of chromedriver
but won't append chromedriver.exe
at the end.Here is the sample code on my Windows 8
system to start Chrome
in Headless Mode
:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get("http://www.duo.com")
print("Chrome Browser Initialized in Headless Mode")
driver.quit()
print("Driver Exited")