I am trying to run a simple code with selenium webdriver chrome on Cloud Function. I get the following error
Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
How do I specify chromedriver executable in Cloud Function?
Below is my code
from selenium import webdriver
import time
def test_webdriver(event=None, context=None):
driver = webdriver.Chrome()
driver.get('http://www.google.com/');
time.sleep(5)
search_box = driver.find_element_by_name('q')
Headless Chrome is not currently available in the Cloud Functions runtime.
If you have the ability to switch to the Node.js runtime for your Cloud Function, you could use puppeteer
which includes headless Chrome, but there is no equivalent for Python.
Another alternative would be to use Cloud Run instead of Cloud Functions. See here for an example: https://dev.to/di/using-headless-chrome-with-cloud-run-3fdp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With