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

[Question] Allow Multiple Downloads Notification #3244

Closed
ok-AK opened this issue Jul 30, 2020 · 3 comments
Closed

[Question] Allow Multiple Downloads Notification #3244

ok-AK opened this issue Jul 30, 2020 · 3 comments
Assignees

Comments

@ok-AK
Copy link

ok-AK commented Jul 30, 2020

Hello,
When using Chrome and attempting to download multiple files at the same time. Chrome displays a notification saying, "Localhost wants to Download multiple files - Allow/Block".

Download Multiple Files - Allow Block

I use a jest-playwright.config.js file to set browser context options. I have the following in my config file and I can successfully test cases involving single file downloads.

jest-playwright.config.js

{
    launchOptions:
    {
		headless: false,
	},
	contextOptions:
	{
		acceptDownloads: true
	},
	browsers: ["chromium"]//, "firefox", "webkit"]
};

Is there a setting or flag I can use to either make the notifications always allow or a download specific setting that will automatically allow multiple files to download? Thanks!

@ok-AK ok-AK changed the title [Question] Multiple Downloads Notification [Question] Allow Multiple Downloads Notification Jul 31, 2020
@aslushnikov
Copy link
Collaborator

@ok-AK I've never seen this dialog in chromium. How do I reproduce this? How do I download multiple files so that this dialog is shown?

@ok-AK
Copy link
Author

ok-AK commented Aug 6, 2020

@aslushnikov
No worries, here's a quick repro CodePen
Note: The two files being downloaded are woff2 files from google fonts
Note: This prompt will only get asked once to you. If you want to see the popup again in Chrome, you will need to go into Chrome settings -> search for automatic downloads -> reset permissions for cdpn.io

In general, Chrome does this whenever a site offers the user the ability to download more than one file at a time instead of zipping the separate files into one.

My use case does not allow me to change the codebase to offer a single zipped file which is why I am going down this multi-download route.

Latest Edge shows the same popup as Chrome (expected I am sure). Firefox treats it differently and prompts for each file but I have not investigated it and I do not need Firefox for my use case.

@dgozman
Copy link
Contributor

dgozman commented Nov 24, 2020

I think you just need to pass acceptDownloads: true option when creating the context.

The following script works for me with Playwright 1.6 and downloads both files:

(async () => {
  const browser = await require('playwright').chromium.launch({ headless: false, downloadsPath: './tmp' });
  const page = await browser.newPage({ acceptDownloads: true });
  await page.goto('https://codepen.io/okak/pen/XWdJjGj');
  const iframe = await page.waitForSelector('iframe#result');
  const frame = await iframe.contentFrame();
  await frame.click('text=Test me using Chrome');
})();

Please reopen if this does not solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants