-1

Selenium -3.141.0 python-2.7 google web driver--74.0.3729.6 google web browser--74.0.3729.169

using below code to access google.com

"from selenium import webdriver

from selenium.webdriver.common.keys import Keys

chrome_options = webdriver.ChromeOptions()

chrome_options.add_argument("headless")

driver = webdriver.Chrome(chrome_options=chrome_options, executable_path="/usr/local/bin/chromedriver")

browser.get('http://www.google.com/')"

getting below issue

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 /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

(Driver info: chromedriver=74.0.3729.6 255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Linux 3.10.0-693.2.2.el7.x86_64 x86_64)

1 Answers1

0
  1. Try executing /usr/bin/google-chrome command in terminal - if it will not be successful - you will not be able to proceed. You can check status code using $? variable - it should be equal to 0
  2. It might be the case there is no DISPLAY variable defined hence Chrome cannot launch properly. Make sure to have this variable defined and pointing to either real or virtual display.
  3. There is a possibility to run Chrome in headless mode, add the next lines to your script:

    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("headless")
    driver = webdriver.Chrome(chrome_options=chrome_options, executable_path="/path/to/chromedriver")
    

    You can see Selenium With Python reference project for example configuration/initialisation

  4. Make sure that ChromeDriver and Chrome versions are matching

Dmitri T
  • 159,985
  • 5
  • 83
  • 133