-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 tests hang waiting on user to interact with download dialog #433
Comments
Nope this requires native events, which have not been implemented in Cypress. There is an issue open #311 but I haven't written the explanation for it. It's orthogonal to #310 though which can give you some perspective. Currently as a workaround just:
|
if the test |
Okay what you should do is isolate the method that ends up making the HTTP request which sends the Then just use You'll need this globally exposed somehow, either attached to some global |
Here's some examples of what I'm referring to: |
Hi @brian-mann |
Just use Alternatively you could set some flags in chrome to force it to accept downloads to a default location and then just assert that the file is present on the file system. |
@brian-mann could you explain more about
How exactly would one do that in their Thanks! |
@jennifer-shehane hmm interesting, I looked briefly but didn't see a flag for auto-accepting downloads. Do you see one? |
No, I was unable to find an appropriate Chrome flag either. @brian-mann you remember which flag you were suggesting?
|
@jennifer-shehane wondering if you find the chrome flag |
This workaround prevents Chrome from trying to download the file: cy.server();
cy.route({
url: '/foo',
status: 304,
response: '',
}).as('foo'); |
Chrome preferences to avoid the download popup are; {
'download.default_directory': <full path to a download directory>,
'profile.default_content_settings.popups': 0
}; However I'm not sure if cypress cli allows setting these. |
@harunhasdal This API comes from Selenium. I don't think there's a way to do this through Cypress currently. I may be wrong, but I think we need to extend Cypress to create an API for these prefs to be passed in - then we pass them onto the Chromium profile. Chromium code using prefs: https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cc#1427 |
@jennifer-shehane thanks for the link, the correct chromium preferences seem to be instead of the selenium ones mentioned above.
I believe, it would be a very useful to be able to configure chromium with a Cypress API. Not only limited to this issue. |
@harunhasdal Can you open a new issue to ask for specifying Chromium preferences in Cypress? There isn't an issue open for this yet. |
@jennifer-shehane Is there any workaround to disable the save prompt when automating downloads in headless Electron? |
@Chase817 I'm not aware of a workaround. |
@Chase817 Two of the approaches we're using in our tests are described here: #949 (comment) Those don't prevent Electron from showing the "save" prompt per se, but instead work around in a way that no file has to actually be downloaded (and yet you get file contents to assert on). |
Closing as duplicate of #949 |
File download is now supported in Cypress 6.3.0. You can now test file downloads in Cypress without the download prompt displaying. Any files downloaded while testing file downloads will be stored in the This means that if you had any code written to prevent the download prompt or to configure the download location (like in a Our file download recipe has been updated, so you can see some ways to test different types of files after they've been downloaded there. If you're encountering any bugs while testing file downloads, please open a new issue. |
Sorry if this is addressed in the documentation – I couldn't find anything on it. When I run a spec, programmatically clicking on a link that downloads a file triggers a download dialog. However, in order to make the test progress, I have to manually dismiss the dialog.
Is there an option that will close download dialogs automatically?
The text was updated successfully, but these errors were encountered: