Selenium Automation

Hey there,
I’m trying to deploy an app that automates a payment with some user-inputted fields. I don’t think all that is important though considering the driver doesn’t run in the first place.

Here is the error I get when I submit the user-inputted form:

File "/home/adminuser/venv/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)

I’ve seen other topics posted with the same issue but I don’t think they were resolved.

Here is the code that produces the issue:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
import schedule
import time

def login(number1, password1):
    options = Options()
    options.add_experimental_option("detach", True)
    options.add_argument('--headless')
    options.add_argument('--disable-gpu')
    options.add_argument("--no-sandbox")
    options.add_argument("--disable-dev-shm-usage")
    options.add_argument("--disable-features=NetworkService")
    options.add_argument("--window-size=1920x1080")
    options.add_argument("--disable-features=VizDisplayCompositor")
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)

All these options arguments are from another post – I’ve just been trying everything but to no avail.

I can post more of my code, too, if someone thinks the problem maybe elsewhere. Thanks!

Hi @shreyanp, and welcome to our forums! :wave:

Could you please send us the full code so that we can better diagnose the issue?

Thanks,
Charly

Yes. Here is the github link to all my code. I am still working on it so I will continually be making changes.

1 Like

Thank you, @shreyanp! :pray:

Also, if you could also provide the full error message and stack trace for better analysis, that would be great!

Meanwhile, here are a few things you can check to diagnose Selenium issues:

  1. Ensure that the ChromeDriver version matches your Chrome browser version.
  2. Try removing the Chrome options one by one, starting with “–headless,” to see if they’re causing the issue.
  3. Manually specify the path to the ChromeDriver executable instead of using ChromeDriverManager().install().

Hopefully these can help you :slight_smile:

@shreyanp - here are three examples of running Selenium on Streamlit Community Cloud:

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

I hope this helps.

Charly

1 Like

Hey, sure, one sec.

Error messages:
File “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 552, in _run_script
exec(code, module.dict)
File “/mount/src/venmobot/website.py”, line 74, in
main()
File “/mount/src/venmobot/website.py”, line 40, in main
st.session_state[“driver”] = vd.loginVenmo(st.session_state[“number”], st.session_state[“password”])
File “/mount/src/venmobot/venmoDriver.py”, line 30, in loginVenmo
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
File “/home/adminuser/venv/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py”, line 45, in init
super().init(
File “/home/adminuser/venv/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py”, line 56, in init
super().init(
File “/home/adminuser/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py”, line 206, in init
self.start_session(capabilities)
File “/home/adminuser/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py”, line 290, in start_session
response = self.execute(Command.NEW_SESSION, caps)[“value”]
File “/home/adminuser/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py”, line 345, in execute
self.error_handler.check_response(response)
File “/home/adminuser/venv/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py”, line 229, in check_response
raise exception_class(message, screen, stacktrace)

Stacktrace:

#0 0x559082b174e3 <unknown>
#1 0x559082846c76 <unknown>
#2 0x55908287404a <unknown>
#3 0x55908286f4a1 <unknown>
#4 0x55908286c029 <unknown>
#5 0x5590828aaccc <unknown>
#6 0x5590828aa47f <unknown>
#7 0x5590828a1de3 <unknown>
#8 0x5590828772dd <unknown>
#9 0x55908287834e <unknown>
#10 0x559082ad73e4 <unknown>
#11 0x559082adb3d7 <unknown>
#12 0x559082ae5b20 <unknown>
#13 0x559082adc023 <unknown>
#14 0x559082aaa1aa <unknown>
#15 0x559082b006b8 <unknown>
#16 0x559082b00847 <unknown>
#17 0x559082b10243 <unknown>
#18 0x7f42610caea7 start_thread

Actually, I think my issue is that my ChromeDriver version doesn’t match my Chrome Broswer version. It says my Chrome Driver only supports Chrome Version 114 but that the Chrome Version is 116. And in terms of the Chrome options, I didn’t have any other than the initial experimental option(“detach”, True)

How can I specify a path when it the ChromeDriver will not be installed on my PC? I’ve installed a ChromeDriver 116 beta in packages but I’m not sure how I can actually use that.

If you are deploying your app on Streamlit Community Cloud, the repos I shared here should help you with path specifications :slight_smile:

Hey,
Unfortunately, the first dude you mentioned’s website displays all the content but doesn’t seem to run Selenium. I implemented his changes (@st.singleton_experimental or whatever which is now @st.cache_resource) but it gave me an error. And the second guy’s repo doesn’t seem to help my specific question. Do you have any other solutions? I have already seen the thread you listed, too.

Hey there,
Did anything help or come up? I am trying to switch the browser to Firefox but I’m getting another error.