puppeteer-sharp: stuck at await browser.NewPageAsync()

I am just trying to create a simple console app to generate PDF file but program doesn’t execute after that line var page = await browser.NewPageAsync(); also i am not getting any exception as program is just stuck. Any help much appreciated. console app code: Using .NET Core 2.2, PuppeteerSharp 1.17.1, C# version 7.1

class Program
   {
       public static async Task Main(string[] args)
       {
           await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
           var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true });
           var page = await browser.NewPageAsync();
           PdfOptions pdfOptions = new PdfOptions();
           pdfOptions.PreferCSSPageSize = true;
           await page.GoToAsync("http://www.google.com", WaitUntilNavigation.Load);
           await page.PdfAsync(Path.Combine(Directory.GetCurrentDirectory(), "google.pdf"), pdfOptions);
       }
     
   }

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 57 (22 by maintainers)

Most upvoted comments

Sure i did that but still stuck on this as well.

I have this issue again in version 5.0.0. I am running Puppeteer Sharp in a Linux Docker container. The issue does not occur when I run it directly on Windows 10.

I am using a translator,

I had the same problem, it worked on one network, but on another it didn’t work, I could only make it work when

`Browser browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true,

IgnoreHTTPSErrors = true, Args = new[] { “–no-sandbox”, “–disable-infobars”, “–disable-setuid-sandbox”, “–ignore-ICertificatePolicy-errors”, }, });`

but I think it was the “–no-sandbox” option that solved it. Was having the same problem on windows 7, I will test if with this option also works.

stuck at browser.NewPageAsync() too.

I just tested with master and the issue is gone, since 28436ad2516d489a98fbdae939773794cf503594 (#1672) to be precise.

update: I tried to open VS by administrator mode which works fine to me.

Does anyone here solve this problem? stuck at browser.NewPageAsync()

uisng v1.20.0 and the bin folder I checked it has .local-chromium folder with Chromium unzipped.

I start the chrome.exe directly which in .local-chromium\Win64-686378\chrome-win folder。 it Can’t open any web pages ,Is this the cause of the problem? @kblok

I’ve solved my problem by using BrowserContext.

BrowserContext browser = _Browser.DefaultContext;
Page p = await browser.NewPageAsync();
            var browser = await Puppeteer.LaunchAsync(new LaunchOptions
            {
                ExecutablePath = @".\chrome.exe",
                Headless = true
            });

            Console.WriteLine(await browser.GetVersionAsync());
            Console.WriteLine(await browser.GetUserAgentAsync());

            Page page = await browser.NewPageAsync();

            Console.WriteLine("end ...");

Version and UserAgent ok but stuck at await browser.NewPageAsync()

@MussaratAziz Hi,I meet the same problem as you, But there is another way to control Chrome.

var browser = await Puppeteer.LaunchAsync(new LaunchOptions
            {
                Headless = true,
               ExecutablePath = Arstrox.HAL.PathResouce.CHROME_EXECUTABLE_PATH

            });

ExcutablePath is the path of Chrome.exe installed on your computer. Also you have to remove the line of await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);