Merge pull request #362 from natethompson44/fix/chromedriver-project-root-priority

fix: prioritize project root ChromeDriver for Docker compatibility
This commit is contained in:
Martin
2025-06-28 14:55:18 +02:00
committed by GitHub
+19 -1
View File
@@ -80,8 +80,25 @@ def install_chromedriver() -> str:
""" """
Install the ChromeDriver if not already installed. Return the path. Install the ChromeDriver if not already installed. Return the path.
""" """
# First try to use chromedriver in the project root directory (as per README)
project_root_chromedriver = "./chromedriver"
if os.path.exists(project_root_chromedriver) and os.access(project_root_chromedriver, os.X_OK):
print(f"Using ChromeDriver from project root: {project_root_chromedriver}")
return project_root_chromedriver
# Then try to use the system-installed chromedriver
chromedriver_path = shutil.which("chromedriver") chromedriver_path = shutil.which("chromedriver")
if not chromedriver_path: if chromedriver_path:
return chromedriver_path
# In Docker environment, try the fixed path
if os.path.exists('/.dockerenv'):
docker_chromedriver_path = "/usr/local/bin/chromedriver"
if os.path.exists(docker_chromedriver_path) and os.access(docker_chromedriver_path, os.X_OK):
print(f"Using Docker ChromeDriver at {docker_chromedriver_path}")
return docker_chromedriver_path
# Fallback to auto-installer only if no other option works
try: try:
print("ChromeDriver not found, attempting to install automatically...") print("ChromeDriver not found, attempting to install automatically...")
chromedriver_path = chromedriver_autoinstaller.install() chromedriver_path = chromedriver_autoinstaller.install()
@@ -92,6 +109,7 @@ def install_chromedriver() -> str:
"and ensure it's in your PATH or specify the path directly." "and ensure it's in your PATH or specify the path directly."
"See know issues in readme if your chrome version is above 115." "See know issues in readme if your chrome version is above 115."
) from e ) from e
if not chromedriver_path: if not chromedriver_path:
raise FileNotFoundError("ChromeDriver not found. Please install it or add it to your PATH.") raise FileNotFoundError("ChromeDriver not found. Please install it or add it to your PATH.")
return chromedriver_path return chromedriver_path