puppeteer-sharp icon indicating copy to clipboard operation
puppeteer-sharp copied to clipboard

Browser crashes when trying to click on href with _blank

Open danbopes opened this issue 5 years ago • 2 comments

Description

Browser closes/crashes when attempting to download very simple file

Complete minimal example reproducing the issue

Complete means the code snippet can be copied into a unit test method in a fresh C# project and run. Minimal means it is stripped from code not related to reproducing the issue.

E.g.

Console.WriteLine("Launching Browser");
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
    Headless = false,
    DefaultViewport = new ViewPortOptions()
    {
        Width = 1600,
        Height = 1200
    },
    UserDataDir = Path.GetFullPath("./user_data")
});

var page = (await browser.PagesAsync())[0];
Directory.CreateDirectory("./downloads");
await page.Client.SendAsync("Page.setDownloadBehavior", new
{
    behavior = "allow",
    downloadPath = Path.GetFullPath("./downloads"),
});
await page.GoToAsync("http://localhost");
await page.WaitForSelectorAsync("a");
Console.WriteLine("Clicking Button");
await page.ClickAsync("a");
await Task.Delay(10 * 1000);
Console.WriteLine("Closing");

Express server:

const express = require('express')
const app = express()
const port = 80

app.use(express.static('public'));

app.get('/download', function(req, res){
    res.download(`${__dirname}/public/download.txt`, 'download1234.txt'); // Set disposition and send it.
});

app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))

public/index.html:

<a href="/download" target="_blank">Click me</a>

Expected behavior:

Browser shouldn't crash/close. Ideally, I should be getting a network request somewhere, that I can capture and pull the filename (download1234.txt).

Actual behavior:

Browser Crashes/Closes

Versions

  • Which version of PuppeteerSharp are you using? v2.0.3
  • Which .NET runtime and version are you targeting? E.g. .NET framework 4.6.1 or .NET Core 2.0. .NET Core 2.0

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue. Logfile can be found here.

danbopes avatar Jun 25 '20 15:06 danbopes

Closed due to inactivity. Feel free to reopen it if needed.

kblok avatar Jul 03 '21 20:07 kblok

@kblok I created a clear reproducible issue, and I cannot reopen...

danbopes avatar Jul 03 '21 21:07 danbopes

This is working with PuppeteerSharp v9

kblok avatar Jan 16 '23 12:01 kblok