I have seen this question come up a number of times before with good solutions.
In fact, i can get this to work when running code from the editor (VS code
).
However, when i create a batch file *.bat
and try to run the same i get this error message:
raise WebDriverException(selenium.common.exceptions.WebDriverException:
Message: 'chromedriver' executable needs to be in PATH. Please see
https://sites.google.com/a/chromium.org/chromedriver/home
The batch file calling the code looks like this:
"C:\Program Files\Python39\python.exe" "Y:\path\to\python_file.py"
The exe and the file are in different folders C:
and Y:
.
I use the usual code for selenium
here:
from selenium import webdriver
PATH = r'Y:\some_path_to\chromedriver.exe'
driver = webdriver.Chrome(PATH)
I have tried: https://sites.google.com/chromium.org/driver/getting-started
I have also tried this: Error message: "'chromedriver' executable needs to be available in the path"
I have also tried to change the os.path: https://www.geeksforgeeks.org/python-os-chdir-method/
I have further tried different methods and variations to get the code running from a batch file (again, the same code runs from the VS code
editor), but am not sure how to resolve the error ?
extra note: I have also tried to change the path in the windows environment: https://zwbetz.com/download-chromedriver-binary-and-add-to-your-path-for-automated-functional-testing/
But this did not work.