M
M
motya882020-02-21 22:22:20
Python
motya88, 2020-02-21 22:22:20

How to solve an error with ChromeDriver?

I ask for your help.
I start the script and 4 times it works without errors, but then an error appears.

from selenium import webdriver
import esia_inf
import time
import esia_inform_insert
import send_email
from pyvirtualdisplay import Display
import traceback
import sent_to_telegram


try:
    print('==================================================')
    dt1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    print('скрипт запущен в ' + dt1)
    display = Display(visible=0, size=(800, 600))
    display.start()
    options = webdriver.ChromeOptions()

    options.add_argument('--no-sandbox')
    options.add_argument('--headless')
    options.add_argument('--disable-dev-shm-usage')

    driver = webdriver.Chrome('/usr/bin/google-chrome',chrome_options=options)
    driver.get('https://test.ru/')


Error logs:
Traceback (most recent call last):
  File "./esia_informer.py", line 23, in <module>
    driver = webdriver.Chrome(chrome_options=options)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, 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.)
  (Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 4.15.0-88-generic x86_64)


how to get rid of the error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2020-02-22
kuzmin @sergueik

motya88
close display
display.stop()
complete chrome

browser.close()
browser.quit()

I think it will pass

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question