Skip to content

[🐛 Bug]: Specifying default download directory for Chrome not working #15469

@TAlvesInfo

Description

@TAlvesInfo

What happened?

Hi everyone,

I’m encountering an issue with ChromeDriver 133.0.6943.53 in my Selenium-based Java application (Spring Boot) running in Ubuntu environment. I wanted to see if anyone has faced a similar problem or has a potential solution.

Background:

I use Selenium with ChromeDriver to perform web scraping and resource downloads. Previously, I was using ChromeDriver 126.0.6478.126, but I encountered an issue where it left zombie processes that eventually crashed my system. Upgrading to version 133.0.6943.53 solved the zombie process issue, but now I’m facing a new problem: the download path I specify is ignored.

The Issue:

I need to handle multiple requests simultaneously, and the files being downloaded have the same name. To avoid conflicts, I assign each request a unique directory based on a GUID (requestId). However, with ChromeDriver 133, the browser downloads the files to the default system directory instead of the custom path I set.

What I've Tried:

Tried different ways to set the download path, but nothing seems to override the default behavior.

Question:

Has anyone experienced a similar issue with ChromeDriver 133? Is there a workaround to force Chrome to respect the download.default_directory setting?

Any insights or suggestions would be greatly appreciated!

Thanks in advance!

How can we reproduce the issue?

Current Configuration:

Here's my ChromeDriver instantiation method:


private ChromeDriver instantiateDriver(boolean headless) {
    ChromeOptions co = new ChromeOptions();
    co.addArguments("--disable-gpu", "--window-size=1920,1200", "--ignore-certificate-errors",
            "--disable-extensions", "--no-sandbox", "--disable-dev-shm-usage");

    if (headless) {
        co.addArguments("--headless",
                "--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
                "--window-size=1920x1080");
    }

    HashMap<String, Object> prefs = new HashMap<>();
    prefs.put("plugins.always_open_pdf_externally", true);
    prefs.put("download.default_directory", linuxPdfPath + requestId + "/");
    prefs.put("download.prompt_for_download", false);

    co.setExperimentalOption("prefs", prefs);

    ChromeDriver driver = null;
    try {
        driver = new ChromeDriver(co);
    } catch (SessionNotCreatedException e) {
        log.error("Driver encountered an issue during initialization...");
        log.error(LogEnum.FAILED.formatLog("instantiateDriver", e.getMessage()));
    }
    return 


Environment Details:

OS: Ubuntu

Selenium with Java (Spring Boot)

ChromeDriver: 133.0.6943.53

Chrome version matches the driver version

Headless mode is required

linuxPdfPath is set to "/var/servicepath/" and requestId is a GUID

Relevant log output

I don't have any errors being throw. My problem is that the download directory remains the default one instead of the one I'm trying to specify

Operating System

Ubuntu

Selenium version

Java 4.7.0

What are the browser(s) and version(s) where you see this issue?

ChromeDriver 133.0.6943.53

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 133.0.6943.53

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!C-javaJava BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions