-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Cypress not downloading file into downloadsFolder
when app code using window.location.href
#20981
Comments
@PCourteille Unfortunately no, I am using Chrome on Mac. |
Hi Alessandro, I don't have any Mac but maybe the issue is similar ? It seems that the Cypress logic is similar with Chrome:
On Mac it will probably be something like:
So my advice is:
If you find something wrong in the path insert by Cypress in your Preference file, you can maybe fix it with the same approach that I did for my Firefox on Windows. Option 2 - Chrome:module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, options) => {
if (browser.family === 'chromium') {
options.preferences.default['download'] = { default_directory: config['downloadsFolder'].replace(/\\/g, "\\\\") }
return options
}
if (browser.family === 'firefox') {
options.preferences['browser.download.folderList'] = 2;
options.preferences['browser.download.dir'] = config['downloadsFolder'].replace(/\\/g, "\\\\");
return options;
}
});
} It's just an example, I don't expect the solution to be the same...
I hope my answer will help you to found a solution, |
Please check issue #17896 A pull request ( #23006 ) to fix this permanently is on the way and was finalized by @AtofStryker (internally it's also double escaping the downloadsFolder path). He wasn't able to reproduce the error on MacOS with the fix in the pull request. When the PR is merged and a new version is released, the workarounds needs to be removed. I think this issue can be closed as a duplicate? |
I am experiencing something similar or the same issue. Though strangely as I was just re-running my tests, it is working now. But based on my previous downloads I was definitely experiencing downloads going to default location in Chrome instead of the configured path. The only thing I did was try a different browser (e.g., Edge) then came back and tried in Chrome. Versions I'm running:
Cypress Version12.3.0 |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
I confirm the issue is still existing. Cypress version 12.16.0. It is downloading the file in the default PC folder "Downloads". |
The same problem here, I'm using chrome, and mac. Cypress version 12.5.1. |
I'm encountering the same issue with above guys. After downloading the CSV file (while using Cypress test runner), the file does not go to the path as setting in cypress-config.js, it goes to the download folder in Mac folder. Cypress version 13.2.0 |
I have a coding interview test that specifically requires verifying downloads :( |
@quynhngx Hi, did you find the solution? I have exactly same issue |
I'm having the same issue with Cypress 13.11.0 using Chrome 126.0.6478.182 on MacOS 14.5. If I check the Chrome's settings (for the instance of Chrome launched by Cypress) I can see that the browser is set to save files in my users' Downloads directory: I expect this setting is meant to be being updated (by Cypress when it launches the browser) but for some reason it is not. If I add @PCourteille's workaround to the Cypress config: on('before:browser:launch', (browser = {}, launchOptions) => {
if (browser.name === 'chrome') {
launchOptions.preferences.default.download = {
default_directory: config['downloadsFolder'].replace(/\\/g, '\\\\'),
}
return launchOptions
}
}) The downloads directory is set correctly in Chrome's settings: and the file downloads there as expected 👍 |
Current behavior
Current app code has an event handler that links to remote url for file download like this:
The file will download, but it won't go into the
downloadsFolder
as specified incypress.json
. Instead, it goes to my machine's user's Downloads directory (probably browser default).Desired behavior
The downloaded file should go to the Cypress
downloadsFolder
directory. My use case is downloading a file into that directory and then uploading / importing it once again.Test code to reproduce
Using the above html snippet and calling it
index.html
:Cypress Version
8.7.0
Other
No response
The text was updated successfully, but these errors were encountered: