How can I update chromedriver on replit for Selenium?

Question:
I want to run selenium on replit using python but I keep getting this error where the chromedriver version is not compatible with the chrome version. I tried to access the mentioned directory via the shell but could not find it. Does anyone know how to solve this issue? Please help me :slight_smile:
Repl link:
https://replit.com/@ilyasben26/Seletest10000002

The chromedriver version (108.0.5359.71) detected in PATH at /nix/store/i85kwq4r351qb5m7mrkl2grv34689l6b-chromedriver-108.0.5359.71/bin/chromedriver might not be compatible with the detected chrome version (115.0.5790.170); currently, chromedriver 115.0.5790.170 is recommended for chrome 115.*, so it is advised to delete the driver in PATH and retry
Traceback (most recent call last):
  File "main.py", line 8, in <module>
    driver = webdriver.Chrome(options=chrome_options)
  File "/home/runner/Seletest10000002/venv/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/runner/Seletest10000002/venv/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 56, in __init__
    super().__init__(
  File "/home/runner/Seletest10000002/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 206, in __init__
    self.start_session(capabilities)
  File "/home/runner/Seletest10000002/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 290, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/home/runner/Seletest10000002/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 345, in execute
    self.error_handler.check_response(response)
  File "/home/runner/Seletest10000002/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /home/runner/.cache/selenium/chrome/linux64/115.0.5790.170/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x55ba329072a3 <unknown>
#1 0x55ba326c5f77 <unknown>
#2 0x55ba326ee5f7 <unknown>
#3 0x55ba326ea7d0 <unknown>
#4 0x55ba3272b0b7 <unknown>
#5 0x55ba3272aa5f <unknown>
#6 0x55ba32722903 <unknown>
#7 0x55ba326f5ece <unknown>
#8 0x55ba326f6fde <unknown>
#9 0x55ba3295763e <unknown>
#10 0x55ba3295ab79 <unknown>
#11 0x55ba3293d89e <unknown>
#12 0x55ba3295ba83 <unknown>
#13 0x55ba32930505 <unknown>
#14 0x55ba3297cca8 <unknown>
#15 0x55ba3297ce36 <unknown>
#16 0x55ba32998333 <unknown>
#17 0x7f2224915e86 start_thread

did you figure it out? I’m having the same problem.

Try to use a webdriver manager: webdriver-manager · PyPI

And change your code to use it:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager

chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

driver = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=chrome_options)
1 Like

EDIT: I realised that chromium --version doesn’t matter because chromium from pkgs.chromium in replit.nix isn’t being used at all at this stage of importing selenium

The latest chromedriver you can get is through the unstable channel: in Shell:

sed -i 's/stable-\w*/unstable/
/stderred/,+1d' .replit

But this still isn’t high enough because replit has to update their nix index, which takes time and makes repls load slowly at first boot.
So, it seems that getting the package that WindLother mentioned to work is the only solution if you must use the latest version of Chrome and Selenium.
Or, if you don’t require it to be Chrome, you could use selenium with Firefox as I’ve done here.
Or, downgrade selenium to support chromedriver v114: in Shell:

poetry add selenium~4.10
4 Likes

Thanks a lot! Downgrading selenium with poetry add selenium@4.10.x fixed the issue.

1 Like

As @UMARismyname said, running poetry add selenium@4.10.x on the shell fixes the issue. I hope this helps :slight_smile:

1 Like

Thank you. the poetry trick worked for me. You’re brilliant!

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