testcafe: Cannot download file by clicking the link with attributes: download, target='_blank' and href='blob:...'

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<a download="hello.txt" href='#' id="link" target="_blank">Download</a>
<script>
    let blob = new Blob(["Hello, world!"], { type: 'text/plain' });

    document.querySelector('#link').href = URL.createObjectURL(blob);
</script>
</body>
</html>
fixture `f`
    .page `http://127.0.0.1:8080`;
test('test', async t => {
    await t.click('a');
    await t.wait(5000);
});

WORKAROUND: use the --disable-multiple-windows flag

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Regarding issue #6946 :- Thank you for your response. Actually we have some dependency around this scenario, could you please take this scenario bit early if possible. Your help will be appreciated.

We have a similar issue in angular12 project:

<a href="javascript:void(0);" class="d-block">Download</a>

by clicking on the link we download the static file.

On click, we see that a new window has been opened but is closed after a few milliseconds, and the file is not downloaded.