Forums

how to solve this error i am unable to use webdriver chrome

.

selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from tab crashed
  (Session info: headless chrome=78.0.3904.70)
  (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 5.4.0-1038-aws x86_64)
------------------------------------
------------------------------------

my code :

from pyvirtualdisplay import Display
from selenium import webdriver


chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")


run  = webdriver.Chrome(options=chrome_options)

I don't see any code to clear things down there, so if you've run your code multiple times, it's likely that a number of Chrome processes have accumulated and are stopping you from starting new ones. You can clear them down using the "Running processes" table at the bottom of the "Consoles" page.

I recommend that you use code that shuts Chrome down properly at the end; something like this:

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(options=chrome_options)

try:
    browser.get("https://www.google.com")
    print("Page title was '{}'".format(browser.title))

finally:
    browser.quit()