Running selenium ChromeDriver on Streamlit Community Cloud

Hi, I am having a lot of trouble getting selenium to work upon deploying my Streamlit app. It was working before my attempted deployment. I swear I’ve followed every possible idea I have found on any forum, but every time, without fail, I get the error:

selenium.common.exceptions.WebDriverException(f"Service {self.path} unexpectedly exited. Status code was: 127")

I have both chromium and chromium-driver in packages.txt plus selenium and seleniumbase in requirements.txt

At the moment, my code looks like this, and it worked before deploying.

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.wait import WebDriverWait
    from selenium.webdriver.support import expected_conditions as ECfrom             
    selenium.webdriver.chrome.options import Options
    chrome_options = Options()
    chrome_options.add_argument("--headless")
    chrome_options.add_argument("--no-sandbox")
    chrome_options.add_argument("--disable-dev-shm-usage")
    chrome_options.add_argument("--disable-gpu")


    #Open new browser window
    driver = webdriver.Chrome(options=chrome_options)

    #Browser goes to auth_url
    driver.get(auth_url)

    #Sets up waiting until the second url to copy the new url
    wait = WebDriverWait(driver, 170)
    wait.until(EC.url_contains("code="))
    url = driver.current_url

    #closes window
    driver.close()

Should I consider deploying a different way?

Hey @amaliajn,

Thanks for sharing your question!

Here are three examples of running Selenium on Streamlit Community Cloud:

  1. @snehankekre’s example:
  1. @Franky1’s example:
  1. @randyzwitch’s example:
3 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.