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]: Can not download a real file with blob url from playwright #33972

Open
zhongkeruanjiansunny opened this issue Dec 12, 2024 · 1 comment

Comments

@zhongkeruanjiansunny
Copy link

Version

1.50

Steps to reproduce

  1. launch a chrome by playwright
  2. input a url "https://clever-elion-84f381.netlify.app/" by hand
  3. click download (link: blob:https://clever-elion-84f381.netlify.app/3d09551b-18a1-42c0-941d-dd8996b62f13) by hand

Expected behavior

chrome download a josn file.

Actual behavior

chrome download a file, but zhe file not a real file,you can not find and open it.....
Image

Additional context

No response

Environment

windows11
chrome 131.0.6778.33
@yury-s
Copy link
Member

yury-s commented Dec 12, 2024

Yeah, I can reproduce it, looks like the file is not actually written to the disk when playwright listens to downloads. The tests with downloads work just fine though, so it only affects manual interaction with the browser controlled by playwright.

import { test, expect } from '@playwright/test';
import fs from 'fs';

test('test', async ({ page }) => {
    const onDownloadPath = new Promise<string>(res => {
        page.on('download', dl => {
        void dl.path().then(res);
        });
    });
    await page.goto('https://clever-elion-84f381.netlify.app/');
    await page.click('a');
    const path = await onDownloadPath;
    expect(fs.readFileSync(path).toString()).toBe('{"foo":1,"bar":2}');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants