-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Context:
- Playwright Version: 0.13.0
- Operating System: macOS
- Extra:
node v13.12.0
Code Snippet
const playwright = require('playwright');
(async () => {
for (const browserType of ['chromium']) {
const browser = await playwright[browserType].launch();
// [RAW] NB: Ensure acceptDownloads is set per https://github.com/microsoft/playwright/blob/bb0b6cd90a9f95c2337ddfcafb516c48318e4c43/docs/api.md#class-download
const context = await browser.newContext({ acceptDownloads: true });
const page = await context.newPage();
page.on("download", (dl) => {
console.log("Captured download:", dl.url());
dl.path().then(console.log).catch(console.error);
});
await page.goto("https://upbeat-nightingale-6e32da.netlify.com/download");
await page.click("text=Download");
await page.waitFor(4_000);
await browser.close();
}
})();
Output:
$ node index.js
Captured download: https://upbeat-nightingale-6e32da.netlify.com/Archive.zip
Error: Pass { acceptDownloads: true } when you are creating your browser context.
at Download.path (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/download.js:41:19)
at Download.<anonymous> (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/helper.js:87:31)
at Page.<anonymous> (/Users/workspace/playwright-downloads/index.js:12:10)
at Page.emit (events.js:315:20)
at new Download (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/download.js:32:20)
at CRBrowser._downloadCreated (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/browser.js:37:26)
at FrameSession._onDownloadWillBegin (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/chromium/crPage.js:535:47)
at CRSession.<anonymous> (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/chromium/crPage.js:275:100)
at CRSession.emit (events.js:315:20)
at /Users/workspace/playwright-downloads/node_modules/playwright-core/lib/chromium/crConnection.js:137:47
-- ASYNC --
at Download.<anonymous> (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/helper.js:66:23)
at Page.<anonymous> (/Users/workspace/playwright-downloads/index.js:12:10)
at Page.emit (events.js:315:20)
at new Download (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/download.js:32:20)
at CRBrowser._downloadCreated (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/browser.js:37:26)
at FrameSession._onDownloadWillBegin (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/chromium/crPage.js:535:47)
at CRSession.<anonymous> (/Users/workspace/playwright-downloads/node_modules/playwright-core/lib/chromium/crPage.js:275:100)
at CRSession.emit (events.js:315:20)
at /Users/workspace/playwright-downloads/node_modules/playwright-core/lib/chromium/crConnection.js:137:47
at runNextTicks (internal/process/task_queues.js:62:5)
Describe the bug
Despite passing { acceptDownloads: true }
to the browser context (per the docs and error message), downloading fails complaining that acceptDownloads
is not set.
Expected Behavior: Archive.zip
is downloaded.
Misc.
Thanks for this amazing project! It's awesome to see the rapid feature development and progress! 🎉
ZeroBrowser
Metadata
Metadata
Assignees
Labels
No labels