evaluateHandle<T extends JsHandle> method
The only difference between Frame.evaluate and Frame.evaluateHandle is that Frame.evaluateHandle returns in-page object (JSHandle).
If the function passed to the Frame.evaluateHandle returns a Promise,
then Frame.evaluateHandle would wait for the promise to resolve and
return its value.
A JavaScript expression can also be passed in instead of a function:
// Get an handle for the 'document'
var aHandle = await frame.evaluateHandle('document');
JSHandle instances can be passed as arguments to the Frame.evaluateHandle:
var aHandle = await frame.evaluateHandle('() => document.body');
var resultHandle = await frame.evaluateHandle(
'body => body.innerHTML',
args: [aHandle],
);
print(await resultHandle.jsonValue);
await resultHandle.dispose();
Parameters:
pageFunctionFunction to be evaluated in the page contextargsArguments to pass topageFunction
returns: Future which resolves to the return value of pageFunction as
in-page object (JSHandle)
Implementation
Future<T> evaluateHandle<T extends JsHandle>(
@Language('js') String pageFunction, {
List<dynamic>? args,
}) {
return _mainWorld.evaluateHandle(pageFunction, args: args);
}