Skip to content

Getting "selenium.common.exceptions.WebDriverException: Message: disconnected: Unable to receive message from renderer" in Driver(uc=True) #2481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iamumairayub opened this issue Feb 11, 2024 · 11 comments
Labels
duplicate The answer/solution already exists somewhere invalid usage You may need to change what you're doing UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode

Comments

@iamumairayub
Copy link

I am getting "selenium.common.exceptions.WebDriverException: Message: disconnected: Unable to receive message from renderer" in Driver(uc=True)

google search suggests adding --no-sandbox and --disable-dev-shm-usage but I can see they are already added in line

I am using Python 3.10 with latest SeleniumBase and here is snippet from my code

from seleniumbase import Driver
from sbvirtualdisplay import Display
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()

prefs = {"profile.managed_default_content_settings.images": 2}
chrome_options.add_experimental_option("prefs", prefs)

with Display(visible=0, size=(1440, 1880)):

    driver = Driver(
        uc=True, 
        browser='chrome',
        cap_string=chrome_options.to_capabilities()
    )
    driver.get('https://www.website.com/')

@mdmintz mdmintz added duplicate The answer/solution already exists somewhere invalid usage You may need to change what you're doing UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode labels Feb 11, 2024
@mdmintz
Copy link
Member

mdmintz commented Feb 11, 2024

cap_string can only be used when connecting to Selenium Grids that support it:
(And UC Mode won't work on a Selenium Grid)

cap_string=None, # The desired capabilities to use with a Selenium Grid.

There's already an option to block images: block_images:

prefs["profile.managed_default_content_settings.images"] = 2

The SB() format might help solve your issue: (https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md#sb_sf_21)
It has extra code for handling those situations.


Duplicate info here: #2334 (comment)

@mdmintz mdmintz closed this as completed Feb 11, 2024
@iamumairayub
Copy link
Author

iamumairayub commented Feb 12, 2024

@mdmintz sorry for confusing you.

My basic purpose was not to disable images.
It was actually to get your suggestion why the selenium.common.exceptions.WebDriverException: Message: disconnected: Unable to receive message from renderer error is happening?

@mdmintz
Copy link
Member

mdmintz commented Feb 12, 2024

That's usually related to Chrome trying to display something in a headless environment such as Linux. Maybe try something from #2426 (reply in thread) - The SB(uc=True) format may be more useful that the Driver(uc=True) format in this case.

@iamumairayub
Copy link
Author

@mdmintz Hi, just letting you know that error still persists even after using SB(uc=True)

@mdmintz
Copy link
Member

mdmintz commented Feb 13, 2024

Try upgrading the version of Chrome on your machine. Looks like it was something that appeared for uses on Chromium 119 and Chromium 120 (Chrome and Edge), but not on newer versions: MicrosoftEdge/EdgeWebDriver#126
(This issue is not specific to SeleniumBase.)

@iamumairayub
Copy link
Author

@mdmintz just did, but issue still persists.

@iamumairayub
Copy link
Author

@mdmintz how do set xvfb window size?

with SB( uc=True, xvfb=True, browser='chrome', ) as sb:
    pass

I used to do it with Driver like this

with Display(visible=0, size=(1600, 900))

@mdmintz
Copy link
Member

mdmintz commented Feb 16, 2024

With SB() and BaseCase, Xvfb is automatically used as needed. Default width: 1440 Default height: 1880

@iamumairayub
Copy link
Author

@mdmintz I understand its not a Python or SB issue. But you have any suggestions for me to fix this?
I am running Google Chrome 120.0.6099.224
I saw your above linked github issue but that guy says upgrading chrome didnt solve issue MicrosoftEdge/EdgeWebDriver#126 (comment)

@iamumairayub
Copy link
Author

One hint is that I have more instances of this script running on server, could that cause some issue with xvfb or something?

@AngeloParra
Copy link

any solution to the problem? @iamumairayub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate The answer/solution already exists somewhere invalid usage You may need to change what you're doing UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode
Projects
None yet
Development

No branches or pull requests

3 participants