[Question] Download starts in new tab
See original GitHub issueHi Team,
there is a download button, after pressing the button a new tab opens and the download starts. After the download is completed, new tab closes. In the chrome browser I see that the file has been downloaded, but const path = await download.path (); shows nothing. VS Code does not show any error.
 const [download] = await Promise.all([
      page.waitForEvent("download"), // wait for download to start
      page.click("span.icon-am-download"),
    ]);
    const path = await download.path();
I think the problem is: A new tab opens, page.waitForEvent (“download”) cannot catch the Download event because the event download is started in new tab.
How can a file be downloaded if the download starts in a new tab?
This is HTML Code:
<div class="column -column">             <button type="button" data-dojo-attach-event="click:_onDownloadClick" class="" data-dojo-attach-point="downloadButton" title="Download Excel">                 <span class="icon-ams-download-3"></span>             </button>         </div>
Thank you very much
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)

 Top Related Medium Post
Top Related Medium Post Top Related StackOverflow Question
Top Related StackOverflow Question
@osmenia your code works in Chromium headless.
There is a TODO in code for Chromium headful: https://github.com/microsoft/playwright/blob/8df1fe47bcc34f0d398f17a37f7a98eabd35b2f5/test/download.spec.ts#L280-L284
@ingvar-nikiforov thanks a lot for your info. wow, i did not try in headless mode,