Unable to run program with Chromedriver : Forums : PythonAnywhere

My program is not running. Locally it runs fine. The code goes to a website, enters firstname & lastname, clicks the search button and saves the resulting page to a screenshot .png file. I am using selenium, webdriver, chromedriver. I am not sure how to set the chromedriver in this case as opposed to m

I installed selenium.

Code:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.print_page_options import PrintOptions

service = Service(executable_path=”/Users/caroline/Documents/Rockfaceit/acucare/python/chromedriver”)
driver = webdriver.Chrome(service=service)

driver.get(“https://exclusions.oig.hhs.gov/”)

input_lname = driver.find_element(By.ID, “ctl00_cpExclusions_txtSPLastName”)
input_lname.send_keys(“Jane”)

input_fname = driver.find_element(By.ID, “ctl00_cpExclusions_txtSPFirstName”)
input_fname.send_keys(“Doe”)

input_search = driver.find_element(By.ID, “ctl00_cpExclusions_ibSearchSP”)
input_search.click()

results_fname = “Jane”
results_lname = “Doe”
results_file_prefix = ‘exclusions-oig-hhs-gov’
results_filename = results_file_prefix + ‘-‘ + results_fname + ‘-‘ + results_lname + ‘.png’

driver.save_screenshot(results_filename)

driver.quit()

Error Message:

Traceback (most recent call last):
File “/usr/local/lib/python3.13/site-packages/selenium/webdriver/common/driver_finder.py”, line 64, in _binary_paths
raise ValueError(f”The path is not a valid file: {path}”)
ValueError: The path is not a valid file: /Users/caroline/Documents/Rockfaceit/acucare/python/chromedriver

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/home/ckyoga2133/acucare/step-one-getfile.py”, line 8, in
driver = webdriver.Chrome(service=service)
File “/usr/local/lib/python3.13/site-packages/selenium/webdriver/chrome/webdriver.py”, line 45, in init
super().init(
~~~~~~~~~~~~~~~~^
browser_name=DesiredCapabilities.CHROME[“browserName”],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
…<3 lines>…
keep_alive=keep_alive,
^^^^^^^^^^^^^^^^^^^^^^
)
^
File “/usr/local/lib/python3.13/site-packages/selenium/webdriver/chromium/webdriver.py”, line 50, in init
if finder.get_browser_path():
~~~~~~~~~~~~~~~~~~~~~~~^^
File “/usr/local/lib/python3.13/site-packages/selenium/webdriver/common/driver_finder.py”, line 47, in get_browser_path
return self._binary_paths()[“browser_path”]
~~~~~~~~~~~~~~~~~~^^
File “/usr/local/lib/python3.13/site-packages/selenium/webdriver/common/driver_finder.py”, line 78, in _binary_paths
raise NoSuchDriverException(msg) from err
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome; For documentation on this error, please visit: www.selen
ium.dev/documentation/webdriver/troubleshooting/errors/driver_location

Read more here: Source link