Reputation: 631
I create a batch file to run Python Selenium, but the browser does not open, but with an error msg
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
my .bat script:
"C:\Users\tom\AppData\Local\Programs\Python\Python37-32\python.exe" "C:\Users\tom\Downloads\selenium.py"
pause
my python code in Jupyter notebook is:
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
time.sleep(3)
driver = webdriver.Chrome('chromedriver.exe')
time.sleep(1)
driver.maximize_window()
time.sleep(1)
driver.set_page_load_timeout('10')
driver.get('https://www.google.com/')
Upvotes: 1
Views: 1884
Reputation: 106
Is ChromeDriver in your PATH? I have had a similar error and was able to resolve it by adding that to my path as the error suggests.
If you don't want to add it to your PATH you should be able to just specify the exact executable location. This should work for you if you replace the path with the correct one.
webdriver.Chrome(executable_path=r'C:\folder\path\to\chromedriver.exe')
Upvotes: 2