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

[BUG] download file not occurs #4233

Closed
yael118 opened this issue Oct 25, 2020 · 4 comments
Closed

[BUG] download file not occurs #4233

yael118 opened this issue Oct 25, 2020 · 4 comments

Comments

@yael118
Copy link

yael118 commented Oct 25, 2020

Context:

  • Playwright Version: [v1.5.1]
  • Operating System: [Windows]
  • Node.js version: [v12.18.4]
  • Browser: [Chromium]

Hi,
after updating to the new playwright version- downloading not really occurs.
using waitForEvent('download') is passing
but the file not really was downloaded

Code Snippet

const os= require('os');
const fs =require('fs')
let userName = os.userInfo().username;
const {chromium, webkit, firefox} = require('playwright');

(async () => {
  const browser = await chromium.launch();
        const context = await browser.newContext();
        const page = await context.newPage();
        await page.goto('https://upbeat-nightingale-6e32da.netlify.app/download');
        await page.click('a');
   
        await page.waitForEvent('download');
        await fs.unlinkSync(`C:\\Users\\${userName}\\Downloads\\Archive.zip`)

})();

Describe the bug
result:
Error: ENOENT: no such file or directory, unlink 'C:\Users\david\Downloads\Archive.zip'

function waitForEvent('download')- succeeded
but it doesn't really happen

@pavelfeldman
Copy link
Member

pavelfeldman commented Oct 26, 2020

You snippet does not enable downloads and does not obtain the downloaded path, so it should not work. Please follow this doc.

@yael118
Copy link
Author

yael118 commented Oct 27, 2020

Thanks for the quick response!!

I fixed the code and it does work.
But I wanted to ask - is there a way to get the file to download to the folder I want on my PC

@arjunattam
Copy link
Contributor

Hi @yael118, you can use downloadsPath to specify the download directory.

const browser = await chromium.launch({ downloadsPath: './temp-dir-for-downloads/' });

I'll close this issue. Feel to comment/create new issue if we are missing anything.

@yael118
Copy link
Author

yael118 commented Nov 1, 2020

Thank you all
Keep up the good work

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