Here are my starting settings (It is NOT headless and you can see the browser opening while navigating)
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = false,
ExecutablePath = ChromePath,
IgnoreHTTPSErrors = true,
Args = new[] { GetInternalBrowserProxySettings(), "--disable-extensions" }
});
and here are some codes before navigation:
var pages = await browser.PagesAsync();
var page = pages[0];
await page.Client.SendAsync("Page.setDownloadBehavior", new
{
behavior = "allow",
downloadPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
});
and then navigating to a file URL (like: https://codeload.github.com/stenzek/duckstation/zip/master)
await page.GoToAsync(url, WaitUntilNavigation.Networkidle2);
The browser will open and it starts downloading the file. I have a timer and I need to stop downloading after 5 seconds. I used this code to stop the page loading:
await page.Client.SendAsync("Page.stopLoading");
It will close the whole browser and the file will delete. I only need to stop downloading the file. How to achieve such a thing?