webdriver.Chrome() error : Message: Unable to locate or obtain driver for chrome
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 02:09 AM
Hi, I've been struggling to run webdriver.Chrome() in my Databricks.
1) I installed a chromedriver :
%sh
# Download ChromeDriver
wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.105/linux64/chromedriver-linux64.zip -O /tmp/chromedriver.zip
# Remove the existing directory if it exists
rm -rf /tmp/chromedriver
mkdir /tmp/chromedriver
unzip /tmp/chromedriver.zip -d /tmp/chromedriver/
chmod +x /tmp/chromedriver/chromedriver-linux64/chromedriver
output :
Archive: /tmp/chromedriver.zip
inflating: /tmp/chromedriver/chromedriver-linux64/LICENSE.chromedriver
inflating: /tmp/chromedriver/chromedriver-linux64/chromedriver
2) check it is indeed installed :
ls /tmp/chromedriver/chromedriver-linux64/
output :
LICENSE.chromedriver chromedriver
3) run the script
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
# Create the Service object with the correct path to chromedriver
chrome_service = Service(executable_path='/tmp/chromedriver/chromedriver-linux64/chromedriver.exe')
options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--disable-extensions")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--no-sandbox")
options.add_experimental_option("prefs",{"download.default_directory":"/databricks/driver"})
# Create the WebDriver instance
driver = webdriver.Chrome(service=chrome_service, options=options)
However, I keep getting this error message "Unable to locate or obtain driver for chrome" in the last line where I run webdriver.Chrome()
Does anyone know what the problem is?
0 REPLIES 0

