Closed
Description
openedon Mar 26, 2021
Context:
- Playwright Version: 1.10.0
- Operating System: Mac
- Node.js version: v15.11.0
- Browser: Chromium, Firefox
Note
This may be related to #3139 (or may even be the same issue, not sure).
Code Snippet
Attempt to download file linked by the following HTML code (href URL shortened):
<div class="o-button-container o-button-container--center u-mb">
<div class="u-mb-small u-mr-small u-pr-xsmall">
<a
href="https://[host].s3.eu-central-1.amazonaws.com/frontend/d8c86afb-091c-4f14-ab33-afd3b7e1a9e1.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&[...];X-Amz-SignedHeaders=host"
target="_blank"
class="c-btn c-btn--link c-btn--small">
<i class="c-btn__icon c-icon c-icon--[semantic-forward]"></i>
<span class="c-btn__text">PDF anzeigen / herunterladen</span></a
>
</div>
</div>
This is the Playwright code that seeks to download the above linked file:
const {chromium, webkit, firefox} = require('playwright');
(async () => {
const browser = await chromium.launch();
// ...
const [download] = await Promise.all([
page.waitForEvent('download'),
await page.click('text=PDF ANZEIGEN'),
]);
await download.saveAs(
path.join(__dirname, 'downloads', download.suggestedFilename())
);
})();
Describe the bug
Expected behavior (works fine when using Firefox):
- File gets downloaded into indicated folder with suggested file name.
- download.saveAs resolves.
Actual behavior (when using Chromium):
- File gets downloaded somewhere (tmp folder?) with GUID as file name.
- download.saveAs does not resolve.
Logs
*** PW API log extract when using Chromium ***
pw:api => page.waitForEvent started +1ms
pw:api => page.click started +1ms
pw:api waiting for event "download" +0ms
pw:api waiting for selector "text=PDF ANZEIGEN" +1ms
pw:api selector resolved to visible <span class="c-btn__text">PDF anzeigen / herunterladen</span> +5s
pw:api attempting click action +19ms
pw:api waiting for element to be visible, enabled and stable +0ms
pw:api element is visible, enabled and stable +33ms
pw:api scrolling into view if needed +0ms
pw:api done scrolling +1ms
pw:api checking that element receives pointer events at (606.47,781.53) +0ms
pw:api element does receive pointer events +2ms
pw:api performing click action +1ms
pw:api click action done +109ms
pw:api waiting for scheduled navigations to finish +0ms
pw:api navigations have finished +123ms
pw:api <= page.click succeeded +1ms
pw:api <= page.waitForEvent succeeded +257ms
pw:api => download.saveAs started +1ms
[then it just keeps waiting for the promise to resolve/reject which doesn't happen...]
*** PW API log extract when using Firefox (URL shortened) ***
pw:api => page.waitForEvent started +0ms
pw:api => page.click started +1ms
pw:api waiting for event "download" +1ms
pw:api waiting for selector "text=PDF ANZEIGEN" +0ms
pw:api selector resolved to visible <span class="c-btn__text">PDF anzeigen / herunterladen</span> +6s
pw:api attempting click action +20ms
pw:api waiting for element to be visible, enabled and stable +1ms
pw:api element is visible, enabled and stable +31ms
pw:api scrolling into view if needed +0ms
pw:api done scrolling +1ms
pw:api checking that element receives pointer events at (606.47,780.73) +1ms
pw:api element does receive pointer events +2ms
pw:api performing click action +1ms
pw:api click action done +26ms
pw:api waiting for scheduled navigations to finish +0ms
pw:api navigations have finished +90ms
pw:api <= page.click succeeded +1ms
pw:api navigated to "about:blank" +111ms
pw:api <= page.waitForEvent succeeded +136ms
pw:api => download.saveAs started +1ms
pw:api navigated to "https://[host].s3.eu-central-1.amazonaws.com/frontend/d8c86afb-091c-4f14-ab33-afd3b7e1a9e1.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&[...];X-Amz-SignedHeaders=host" +2ms
pw:api "load" event fired +1ms
pw:api <= download.saveAs succeeded +160ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment