0

Many people have tried to answer it in org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser but none of the solution seem to work unless I add the --headless options.

Environment Details

    selenium==3.141.0
    Google Chrome 73.0.3683.103
    Driver Used -- 73.0.3683.68 -- chromedriver_linux64.zip
    OS -- Linux 16.04
    Python -- 3.5.2

The Error I am facing is below:

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=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.4.0-17134-Microsoft x86_64)

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    import time

    options = webdriver.ChromeOptions()
    options.add_argument("start-maximized")
    options.add_argument("--no-sandbox")
    # options.add_argument("--headless")
    options.add_argument("--disable-gpu")
    options.add_argument("--disable-dev-shm-usage")
    options.add_argument("-window-size=1400,1400")

    driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver',options=options)

    driver.get('https://www.google.com')
    driver.maximize_window()
    print(driver.page_source)
    driver.quit()
NMAK
  • 209
  • 2
  • 9
  • @DebanjanB, I have managed to work this out in windows environment succeessfully. However it does not answer my question to use chrome successfully, because the /usr/bin/google-chrome is being configured already and the chromedriver is also mentioned in the executable path. The versions also match. I believe many people are facing this issue, as I have stated, if I use headless browser it works perfectly fine. But, when I try to open a browser session, it does not work and ends up in the error stated in the question. – NMAK Apr 16 '19 at 15:16

1 Answers1

-1

I am not sure about the code, but here is a typo with the dashes.

options.add_argument("-window-size=1400,1400")

Also, I think you need dashes in front of the start-maximized too.

Edit: I checked on geckodriver and it seems to run without problems, maybe try chrome_options instead of options, but other than this, I have no idea.

Edit2: that line opens an empty page which you can't get the source code of. Try to clean up your code, it seems to be copy paste from various sources. Also start-maximized already does maximize_window, but I am not sure if start-maximized works in chromedriver, so try to stick to only one.