Summary
Hello there! My app of using selenium worked on localhost but on streamlit cloud, it don’t worked. Please tell me how to fix.
Steps to reproduce
Code snippet:
import streamlit as st
import os
import re
from PIL import Image
import shutil
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
import subprocess
from webdriver_manager.chrome import ChromeDriverManager
cmd = 'pip install --upgrade chromedriver_binary'
res = subprocess.call(cmd, shell=True)
chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs",prefs)
chrome_options.add_argument('--headless')
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=chrome_options)
# driver = webdriver.Chrome(executable_path=r'C:\Users\hskw1\git_space\llamaindex_ocr\chromedriver')
driver.get('https://www3.nohhi.co.jp/rktrace/trace.html')
search_bar = driver.find_element_by_name("command5")
search_bar.send_keys(num) # num is variable. order number
search_bar.submit()
Error:
2023-08-17 22:13:40.393 Uncaught app exception
Traceback (most recent call last):
File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
exec(code, module.__dict__)
File "/mount/src/llamaindex_ocr/main.py", line 70, in <module>
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=chrome_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/adminuser/venv/lib/python3.11/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/home/adminuser/venv/lib/python3.11/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/home/adminuser/venv/lib/python3.11/site-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service /home/appuser/.wdm/drivers/chromedriver/linux64/114.0.5735.90/chromedriver unexpectedly exited. Status code was: 127