Skip to content

[🐛 Bug]: Selenium C# doesn't set the default directory as configured. #17762

Description

@Giorgio6846

Description

Even though the download directory is explicitly configured in Selenium:

options.AddUserProfilePreference("download.default_directory", _downloadPath);
options.AddUserProfilePreference("savefile.default_directory", _downloadPath);

Chrome ignores these settings when running inside the Docker container. According to the debugging logs, the configured download path is not being honored, and files are downloaded elsewhere.

The same configuration works correctly when using Selenium with Python, but it fails when using Selenium with C#.

Environment details:
Selenium C#: 4.45.0
Docker Image: selenium/standalone-chrome:149.0-20260606

Reproducible Code

public void CreateDriver()
        {

            var options = new ChromeOptions
            {
                UseWebSocketUrl = true,
                EnableDownloads = true,
                AcceptInsecureCertificates = true,
            };
            //options.AddAdditionalOption("webSocketUrl", true);
            //options.set_capability("goog:loggingPrefs", { "performance": "ALL"});.

            options.AddArgument("--no-sandbox");
            options.AddArgument("--disable-notifications");
            options.AddArgument("--disable-gpu");
            options.AddArgument("--disable-infobars");
            options.AddArgument("--disable-extensions");
            options.AddArgument("--disable-application-cache");
            options.AddArgument("--disable-dev-shm-usage");
            options.AddArgument("--window-size=1920,1080");
            options.AddArgument("--disable-blink-features=AutomationControlled");
            options.AddArgument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36");
            options.AddArgument("--ignore-certificate-errors");

            options.AddUserProfilePreference("profile.default_content_setting_values.automatic_downloads", 1);
            options.AddUserProfilePreference("download.default_directory", _downloadPath);
            options.AddUserProfilePreference("savefile.default_directory", _downloadPath);
            options.AddUserProfilePreference("download.prompt_for_download", false);
            options.AddUserProfilePreference("download.directory_upgrade", true);

            options.AddUserProfilePreference("safebrowsing.enabled", true);
            options.AddUserProfilePreference("disable-popup-blocking", "true");

        
            //options.AddArgument("disable-popup-blocking");
            //options.add_experimental_option("prefs", prefs)

            Driver = new RemoteWebDriver(
                new Uri(_remoteUrl),
                options);
        }

Debugging Logs

[Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [--no-sandbox, --disable-notifications, --disable-gpu, --disable-infobars, --disable-extensions, --disable-application-cache, --disable-dev-shm-usage, --window-size=1920,1080, --disable-blink-features=Au..., user-agent=Mozilla/5.0 (Win..., --ignore-certificate-errors], prefs: {disable-popup-blocking: true, download.default_directory: /download/robot_1/tmp_txt, download.directory_upgrade: true, download.prompt_for_download: false, safebrowsing.enabled: true, savefile.default_directory: /download/robot_1/tmp_txt}}, se:downloadsEnabled: true, webSocketUrl: true}]
2026-07-10 12:13:16


17:13:16.068 INFO [LocalNode.newSession] - Using file system: /tmp/uuid13158725624210186930db21d581-1050-4f79-ab53-155c8b8c3687
2026-07-10 12:13:16


17:13:16.069 INFO [LocalNode.setDownloadsDirectory] - Using downloads folder: /tmp/uuid13158725624210186930db21d581-1050-4f79-ab53-155c8b8c3687/download4000331621100967802
2026-07-10 12:13:16


17:13:16.069 DEBUG [LocalNode.setDownloadsDirectory] - Adding to capabilities: {download.default_directory=/tmp/uuid13158725624210186930db21d581-1050-4f79-ab53-155c8b8c3687/download4000331621100967802, savefile.default_directory=/tmp/uuid13158725624210186930db21d581-1050-4f79-ab53-155c8b8c3687/download4000331621100967802, download.prompt_for_download=false}

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-gridEverything grid and server relatedC-dotnet.NET BindingsD-chromeI-defectSomething is not working as intendedJ-awaiting answerQuestion asked of user; a reply moves it to triage againOS-linux

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions