Skip to content
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

[🐛 Bug]: Cannot Set Custom Download Directory in Selenium 4.27.0 #14886

Open
maldanus opened this issue Dec 10, 2024 · 2 comments
Open

[🐛 Bug]: Cannot Set Custom Download Directory in Selenium 4.27.0 #14886

maldanus opened this issue Dec 10, 2024 · 2 comments
Labels
I-defect I-issue-template Applied to issues not following the template, or missing information.

Comments

@maldanus
Copy link

What happened?

When attempting to set a custom download directory using the download.default_directory preference in Selenium, the setting is always overwritten to /home/user/Downloads. I have tried multiple directory paths including:

/tmp/

Project root directory

Subfolders within the project

How can we reproduce the issue?

Environment:

Selenium Version: 4.27.0

Java Version: 17

Operating System: Xubuntu 24

ChromeDriver Version: 131.0.6778.87

Chromium Version: 131.0.6778.87

Map<String, Object> prefs = new HashMap<>();
prefs.put("download.default_directory", downloadFilePath);
prefs.put("download.prompt_for_download", false);
prefs.put("download.directory_upgrade", true);
prefs.put("safebrowsing.enabled", true);
options.setExperimentalOption("prefs", prefs);



Expected Behavior:

The browser should use the specified download.default_directory for file downloads.

Actual Behavior:

The download directory is always set to /home/user/Downloads, ignoring the specified download.default_directory.

Steps to Reproduce:

Create a Selenium project using Java and include the above configuration for ChromeOptions.

Specify a custom download directory (e.g., /tmp/ or a project subfolder).

Run the test and observe the download location.

Additional Information:

Verified that the downloadFilePath variable contains a valid absolute path.

Tested with different paths, but the issue persists.

Other preferences (e.g., safebrowsing.enabled) are applied successfully.

Request:

Please investigate if this is a bug or if there are additional steps required to ensure the download.default_directory setting is applied correctly. Let me know if further details or logs are needed.

Relevant log output

[1733864025.508][INFO]: Starting ChromeDriver 131.0.6778.87 (ce31cae9487357cfd3bd62984ed5250121a71a23-refs/branch-heads/6778@{#2287}) on port 24175
[1733864025.508][INFO]: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1733864025.509][INFO]: ChromeDriver was started successfully on port 24175
[1733864025.581][INFO]: [e0093efdaa4cda4c8ae9d2d775f00db4] COMMAND InitSession {
   "capabilities": {
      "firstMatch": [ {
         "browserName": "chrome",
         "goog:chromeOptions": {
            "args": [ "--no-sandbox", "--disable-dev-shm-usage", "--disable-gpu", "--disable-extensions", "--disable-infobars", "--disable-notifications", "--user-data-dir=ProjectDirServer/files/chromeProfile" ],
            "binary": "selenium/chrome-linux64/chrome",
            "extensions": [  ],
            "prefs": {
               "download.default_directory": "/tmp/down",
               "download.directory_upgrade": true,
               "download.prompt_for_download": false,
               "safebrowsing.enabled": true
            }
         }
      } ]
   },
   "desiredCapabilities": {
      "browserName": "chrome",
      "goog:chromeOptions": {
         "args": [ "--no-sandbox", "--disable-dev-shm-usage", "--disable-gpu", "--disable-extensions", "--disable-infobars", "--disable-notifications", "--user-data-dir=ProjectDirServer/files/chromeProfile" ],
         "binary": "selenium/chrome-linux64/chrome",
         "extensions": [  ],
         "prefs": {
            "download.default_directory": "/tmp/down",
            "download.directory_upgrade": true,
            "download.prompt_for_download": false,
            "safebrowsing.enabled": true
         }
      }
   }
}
[1733864025.581][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "download": {
      "default_directory": "/tmp/down",
      "directory_upgrade": true,
      "prompt_for_download": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": true
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}

Operating System

Xubuntu 24

Selenium version

Java 4.27.0

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

ChromeDriver Version: 131

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

ChromeDriver Version: 131.0.6778.87

Are you using Selenium Grid?

No response

Copy link

@maldanus, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol diemol added I-issue-template Applied to issues not following the template, or missing information. and removed needs-triaging labels Dec 11, 2024
Copy link

Hi, @maldanus.
Please follow the issue template, we need more information to reproduce the issue.

Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue.

Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough.

Reply to this issue when all information is provided, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-defect I-issue-template Applied to issues not following the template, or missing information.
Projects
None yet
Development

No branches or pull requests

2 participants