queryObjects method

Future<JsHandle> queryObjects(
  1. JsHandle prototypeHandle
)

The method iterates the JavaScript heap and finds all the objects with the given prototype.

// Create a Map object
await page.evaluate('() => window.map = new Map()');
// Get a handle to the Map object prototype
var mapPrototype = await page.evaluateHandle('() => Map.prototype');
// Query all map instances into an array
var mapInstances = await page.queryObjects(mapPrototype);
// Count amount of map objects in heap
var count = await page.evaluate('maps => maps.length', args: [mapInstances]);
await mapInstances.dispose();
await mapPrototype.dispose();

Shortcut for Page.mainFrame.executionContext.queryObjects.

Parameters: prototypeHandle: A handle to the object prototype.

Returns a Future which completes to a handle to an array of objects with this prototype.

Implementation

Future<JsHandle> queryObjects(JsHandle prototypeHandle) async {
  var context = await mainFrame.executionContext;
  return context.queryObjects(prototypeHandle);
}