Skip to content

[πŸ› Bug]: Get error session not created: probably user data directory is already in use when updating to chrome 138Β #16065

@davee1

Description

@davee1

Description

I am using selenium with c#, .net 9. Have been using for the past several years to scrape web pages since .net core 5. Has been working great. Had the exact same configuration for several years. When upgrading from 137 to 138 (just tested chromedriver 138.0.7204.157, also fails in 139). When I call
Browser = new ChromeDriver(path, options);
I get
BaseWeb.ctor: Could not create browser
System.InvalidOperationException: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir (SessionNotCreated)
at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
at OpenQA.Selenium.WebDriver.ExecuteAsync(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters)
at OpenQA.Selenium.WebDriver.StartSession(ICapabilities capabilities)
at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options)
at Geonovi.WebBrowser.BaseWeb.StartBrowser(Boolean incognito, Boolean hideBrowser) in C:\src\phoenix\WebBrowser\BaseWeb.cs:line 120

I am not setting user-data-dir. The options I am setting are
var options = new ChromeOptions()
{
BinaryLocation = chromeLocation, //path to chrome.exe
};
DirectoryInfo dir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));
DownloadPath = dir.FullName;
options.AddUserProfilePreference("download.default_directory", DownloadPath);
options.AddExcludedArgument("enable-automation");
options.AddAdditionalChromeOption("useAutomationExtension", false);
options.AddArgument("--disable-blink-features=AutomationControlled");

The exact same code works fine with 137 or earlier, but fails with 138 or later.

Reproducible Code

var options = new ChromeOptions()
{
    BinaryLocation = chromeLocation,  //path to chrome.exe
};
DirectoryInfo dir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));
DownloadPath = dir.FullName;
options.AddUserProfilePreference("download.default_directory", DownloadPath);
options.AddExcludedArgument("enable-automation");
options.AddAdditionalChromeOption("useAutomationExtension", false);
options.AddArgument("--disable-blink-features=AutomationControlled");
Browser = new ChromeDriver(path, options);  //path is set to chromedriver path

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!C-dotnet.NET BindingsD-chromeG-chromedriverRequires fixes in ChromeDriverI-defectSomething is not working as intendedI-regressionSomething was working but we "fixed" itOS-windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions