-1

I wrote this little test script in Python experiment a bit with selenium

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from time import sleep

options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)

driver.get("youtube.com")
print(driver.title)
driver.close()

I followed this tutorial and at first everything worked but after tried the same script without me touching anything I got this error message:

/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
  File "/minecraft-server/test.py", line 10, in <module>
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
    super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
    super().__init__(
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 270, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 363, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 428, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x56082467b693 <unknown>
#1 0x560824474b0a <unknown>
#2 0x560824499ef2 <unknown>
#3 0x5608244951f4 <unknown>
#4 0x5608244d0953 <unknown>
#5 0x5608244ca743 <unknown>
#6 0x5608244a0533 <unknown>
#7 0x5608244a1715 <unknown>
#8 0x5608246cb7bd <unknown>
#9 0x5608246cebf9 <unknown>
#10 0x5608246b0f2e <unknown>
#11 0x5608246cf9b3 <unknown>
#12 0x5608246a4e4f <unknown>
#13 0x5608246eeea8 <unknown>
#14 0x5608246ef052 <unknown>
#15 0x56082470971f <unknown>
#16 0x7fa7f4446609 <unknown>

This script was executed on a Ubuntu 20.04.5 LTS Server using Python 3.10.7 and Chrome 105.0.5195.102

LeoCodes
  • 11
  • 2

1 Answers1

0

Big facepalm for you... try to replace:

driver.get("youtube.com")

with:

driver.get("https://www.youtube.com/")

lol

Carapace
  • 377
  • 2
  • 9
  • Doesn't change anything :/ same error as mentioned above – LeoCodes Sep 13 '22 at 08:46
  • To me it works with that change. Anyway I just read you error log and it says `"urllib3 ({}) or chardet ({}) doesn't match a supported`. Did you try to google it? https://stackoverflow.com/questions/50202238/python-pip-requestsdependencywarning-urllib3-1-9-1-or-chardet-2-3-0-doe – Carapace Sep 13 '22 at 08:49
  • I dont think that this warning has to do something with my error, I think I even had it before my script broke. The link you posted is a complete other error also he's using pyhton 2.7 which is a complete other version – LeoCodes Sep 13 '22 at 11:19
  • I now run `pip3 install --upgrade requests` and the first two lines of my error went away, rest stayed the same – LeoCodes Sep 13 '22 at 11:31
  • [Try this](https://stackoverflow.com/questions/25311593/chromewebdriver-unknown-error-chrome-failed-to-start-crashed) – Carapace Sep 13 '22 at 12:02
  • No, reinstalling didn't work either – LeoCodes Sep 13 '22 at 14:03