0

I'm running the following code from the docs.

PuppeteerSharp.Browser browser = await Puppeteer
  .LaunchAsync(new LaunchOptions { Headless = true });
Page page = await browser.NewPageAsync();
Response x = await page.GoToAsync("http://www.google.com");

When I step through the code, after the first line is executed, the console program exits. No error, no nothing - just a finished off execution. I don't really understand why it happens.

I'm trying to use a headless browser to access a page and emulate a click on a button. First step would be to obtain the page, as I'm trying with google.com but it seems not to perform.

I've googled for other examples but all that regard C# lead to their webpage with the examples I linked to.

What should I do to make the page accessible for my clicking?

Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
  • Do you have `await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);`? – hardkoded Sep 06 '19 at 20:52
  • Yes. I tried that too and it seems to exit the program when executing that line. Then I tried to skip the line so I run on a default browser, whatever that might be. At this stage, I just want a sample that shows how to access a page and click a button. I sense that I'm approaching it all wrong, though... – Konrad Viltersten Sep 06 '19 at 21:04
  • The demo should work https://github.com/kblok/puppeteer-sharp/tree/master/demos – hardkoded Sep 06 '19 at 21:07
  • @hardkoded Interesting. When I run the demo, it downloads the browser. In the cloned project, it does something. When I copy over the contents of `Main` to my project, the exit with no exception occurs still. Rather confusing and hard to debug. – Konrad Viltersten Sep 06 '19 at 21:27

0 Answers0