5

In Puppeteer you can evaluate async functions:

await page.evaluate(async () => {
    // await some promise
});

Is there an equivalent in PuppeteerSharp? Using EvaluateFunctionAsync, the task completes before the promise resolves:

await page.EvaluateFunctionAsync(@"async () => {
    // await some promise
}");
Eric Eskildsen
  • 4,269
  • 2
  • 38
  • 55

1 Answers1

10

That's the right way, for example:

var six = await page.EvaluateFunctionAsync<int>("async () => await Promise.resolve(6)");
Meir Blachman
  • 325
  • 2
  • 6