evaluate<T> method

Future<T?> evaluate<T>(
  1. @Language('js') String pageFunction, {
  2. List? args,
})

This method passes this handle as the first argument to pageFunction.

If pageFunction returns a Future, then handle.evaluate would wait for the promise to resolve and return its value.

Examples:

var tweetHandle = await page.$('.tweet .retweets');
expect(await tweetHandle.evaluate('node => node.innerText'), '10');

Parameters:

  • pageFunction Function to be evaluated in browser context
  • args Arguments to pass to pageFunction
  • returns: Future which resolves to the return value of pageFunction

Implementation

Future<T?> evaluate<T>(@Language('js') String pageFunction,
    {List<dynamic>? args}) {
  return executionContext.evaluate(pageFunction, args: [this, ...?args]);
}