SessionNotCreatedException: Message: session not created from disconnected: unable to connect to renderer with ChromeDriver 2.45 Chrome v71
A

7

6

When I'm executing this code with Selenium using Python:

from selenium import webdriver
from selenium.webdriver.common.by import By
import time
driver = webdriver.Chrome(executable_path=r'/Users/qa/Documents/Python/chromedriver')

The error occurred:

   Traceback (most recent call last):
  File "/Users/qa/Documents/Python/try.py", line 4, in <module>
    driver = webdriver.Chrome(executable_path=r'/Users/qa/Documents/Python/chromedriver')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer
  (Session info: chrome=71.0.3578.98)
  (Driver info: chromedriver=2.44.609545 (c2f88692e98ce7233d2df7c724465ecacfe74df5),platform=Mac OS X 10.13.6 x86_64)

Can someone help me? Thanks.

Apodictic answered 17/12, 2018 at 3:36 Comment(6)
Update the question with the error trace logs.Troopship
Im using mac high sierra and I already tried to use 2.44 and 2.43 that are also support Chrome v71. I still have an error sir.Apodictic
I got an error when I remove the executable_path parameter. 'chromedriver' executable needs to be in PATH. @DebanjanBApodictic
I was looking for the error stack traceTroopship
@DebanjanB Sorry sir. Ive already edit and add the Error TracebackApodictic
duplicate of #53320642Acetous
T
4

This error message...

selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

You need to consider a fact:

  • As you are using Mac OS X the Key executable_path must be supported with a Value as :

    '/Users/qa/Documents/Python/chromedriver'
    
  • So line will be:

    driver = webdriver.Chrome(executable_path='/Users/qa/Documents/Python/chromedriver')
    

Note: The path itself is a raw path so you don't need to add the switch r and drop it.

Additionally, ensure that /etc/hosts on your system contains the following entry :

127.0.0.1 localhost.localdomain localhost
#or
127.0.0.1 localhost loopback
Troopship answered 17/12, 2018 at 5:54 Comment(2)
It works sir and I also edit my hosts because my localhost is blocked. ThanksApodictic
My hosts contains the config but still facing this problem. I did not know what to do to fix it .@DebanjanB #70144201Idea
R
12

I had a similar error, first getting the error message:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited normally. (unknown error: DevToolsActivePort file doesn't exist)

This was solved by adding options.add_argument("--remote-debugging-port=9230") to the ChromeOptions(). And the program runs once and I gained the same error message as above:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created from disconnected: unable to connect to renderer (Session info: headless chrome=89.0.4389.114)

The problem here was that the chrome process does not close properly in the program so the process is still active on the debugging-port. To solve this problem close the active port sudo kill -9 $(sudo lsof -t -i:9230) and simply add the following lines to the end of the code:

driver.stop_client()
driver.close()
driver.quit()

Since I didn't find this answer anywhere, I hope it helps someone.

Rockett answered 8/4, 2021 at 10:7 Comment(0)
L
10

If you have options.add_argument("--remote-debugging-port=9222") change this to options.add_argument("--remote-debugging-port=9230")

or just simply Adding options.add_argument("--remote-debugging-port=9230") fixed in my case.

Loutitia answered 16/9, 2021 at 9:8 Comment(1)
I do not know why, it did not work for me. I am using a debian docker image.Idea
T
4

This error message...

selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

You need to consider a fact:

  • As you are using Mac OS X the Key executable_path must be supported with a Value as :

    '/Users/qa/Documents/Python/chromedriver'
    
  • So line will be:

    driver = webdriver.Chrome(executable_path='/Users/qa/Documents/Python/chromedriver')
    

Note: The path itself is a raw path so you don't need to add the switch r and drop it.

Additionally, ensure that /etc/hosts on your system contains the following entry :

127.0.0.1 localhost.localdomain localhost
#or
127.0.0.1 localhost loopback
Troopship answered 17/12, 2018 at 5:54 Comment(2)
It works sir and I also edit my hosts because my localhost is blocked. ThanksApodictic
My hosts contains the config but still facing this problem. I did not know what to do to fix it .@DebanjanB #70144201Idea
A
2

I ran into this same issue on a Windows 10 machine. What I had to do to resolve the issue was to open the Task Manager and exit all Python.exe processes, along with all Chrome.exe processes. After doing this,

Antetype answered 22/7, 2020 at 19:32 Comment(0)
I
1

I am facing the same error and add the close code solve the problem, the code finnaly block look like this:

    @staticmethod
    def fetch_music_download_url(music_name: str):
        chrome_driver_service = Service(ChromeDriverManager(chrome_type=ChromeType.GOOGLE).install())
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        chrome_options.add_argument("--no-sandbox")
        chrome_options.add_argument("--disable-gpu")
        chrome_options.add_argument("--remote-debugging-port=9230")
        driver = webdriver.Chrome(service=chrome_driver_service, options=chrome_options)
        try:
            driver.maximize_window()
            driver.get('http://example.cn/music/?page=audioPage&type=migu&name=' + music_name)
            driver.implicitly_wait(5)
            // do some logic
        except Exception as e:
            logger.error(e)
        finally:
            // add the close logic
            driver.stop_client()
            driver.close()
            driver.quit()
            chrome_driver_service.stop()

the key is you should close the chrome service after using it by add chrome_driver_service.stop().hope this code could help other people facing the same issue.

Idea answered 29/11, 2021 at 13:42 Comment(0)
H
0

This worked for me on WINDOWS OS

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

options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
driver = webdriver.Chrome(options=options)
driver.get(url)
time.sleep(3)
page = driver.page_source
driver.quit()
soup = BeautifulSoup(page, 'html.parser')

Hope you'd find this useful. I also used it more comprehensively here.

Honewort answered 7/1, 2022 at 16:7 Comment(0)
F
0

I was facing the same issue with selenium. Adding this helped in my case.

options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
options.add_argument('--disable-setuid-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("--start-maximized")
options.add_argument("--window-size=1920,1080")
Frederick answered 13/6 at 6:12 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Deary

© 2022 - 2024 — McMap. All rights reserved.