Skip to content

'Unable to receive message from renderer' error after setting userDataDir #85

@anastasiam

Description

@anastasiam

Hello!

When setting userDataDir and navigating to a url I get an error Unable to receive message from renderer in console output. When I try to do anything else, after this message appears, I get OpenQA.Selenium.WebDriverException: disconnected: not connected to DevTools exception.
If userDataDir is not being set it works perfectly fine.

Error in console:
Screenshot 2024-08-14 174802

Exception:

OpenQA.Selenium.WebDriverException: disconnected: not connected to DevTools
  (failed to check if window was closed: disconnected: not connected to DevTools)
  (Session info: chrome=127.0.6533.101)
   at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebDriver.GetScreenshot()

My code:

using var chromeDriver = UndetectedChromeDriver.Create(
    headless: true,
    driverExecutablePath: await new ChromeDriverInstaller().Auto(),
    userDataDir: $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\Google\Chrome\User Data"
);

Console.WriteLine("Navigating to nowsecure.nl...");
chromeDriver.GoToUrl("https://nowsecure.nl");
        
Console.WriteLine("Getting screenshot...");
var screenshot = chromeDriver.GetScreenshot();

Even though I set headless: true, it behaves like it's set to false. The window is opening, navigating to the url and closing immediately.

I would appreciate any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions