question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Download starts in new tab

See original GitHub issue

Hi 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:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ingvar-nikiforovcommented, Sep 8, 2020

@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

0reactions
osmeniacommented, Sep 8, 2020

@ingvar-nikiforov thanks a lot for your info. wow, i did not try in headless mode,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reason to start download in same tab vs new tab?
I got you but my scenario is when user clicked the download link, the browser opens a new tab -> start download ->...
Read more >
Links forcing download instead of opening in a new tab
Click on a link inside of a view or form with open the Save As window to begin the download, instead of opening...
Read more >
Force file link to open as a preview in [new] tab (instead of ...
Press the ctrl button while you click the image, it opens the image in new tab. I hope this works for users having...
Read more >
Reset Chrome settings to default - Google Chrome Help
What changes when you restore your settings · Default search engine, which is changed back to Google. · Homepage and tabs. · The...
Read more >
Frequently asked questions - Zoom Support
My Zoom account; Troubleshooting; How to use additional Zoom products. Getting started with Zoom. Where do I download the latest version of Zoom ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found