Headless Chrome Browser Simulations Fail to Start a Simulation

Summary:

The Browser Simulations have been updated to use headless chrome; however, the simulations are unable to start a new session and fail immediately and generate the following error :

...
...
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesnt exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Steps to reproduce:

This can be reproduced using the example provided in the browser simulation check or something as simple as:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get('{{localhost}}/index.html')
driver.implicitly_wait(1)

assert(True)
driver.close()

Thanks for reporting @TroyDundas! We’ll take a look.

Hi @TroyDundas,

The example for the browser simulations was incomplete. I’ve updated it and we’ll deploy that update shortly, but for now here is the boilerplate code to use for browser simulations.

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome(options=options)
driver.get('{{localhost}}/index.html') # Load the page you want to test.
driver.implicitly_wait(1)

try:
    # Replace this try block with your test code.
    driver.find_element_by_id('clickMe').click()
    elm = driver.find_element_by_css_selector('ul#list li:first-child')
    assert(elm.text == 'Clicked button')
finally:
    driver.close()

Let me know if you have any questions or if you encounter any more issues!

1 Like