new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · API reference · all subjects

jshandle/methods

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

JSHandle.asElement method

The asElement method is synchronous and returns either null or the object handle itself if the object handle is an instance of ElementHandle.

JSHandle.dispose method

The dispose method is async and stops referencing the element handle. It prevents the referenced JavaScript object from being garbage collected.

JSHandle.evaluateHandle method

The evaluateHandle method is async and returns a JSHandle. It returns the return value of the expression parameter as a JSHandle. This method passes this handle as the first argument to the expression. The only difference between jsHandle.evaluate and jsHandle.evaluateHandle is that jsHandle.evaluateHandle returns JSHandle. If the function passed returns a Promise, then jsHandle.evaluateHandle waits for the promise to resolve and returns its value. The method takes parameters: expression (required, a function or string), arg (optional, EvaluationArgument to pass to the expression), and exposeFunctions option (since v1.62).

JSHandle.getProperties method

The getProperties method is async and returns a Map with string keys and JSHandle values. The method returns a map with own property names as keys and JSHandle instances for the property values.

JSHandle.getProperty method

The getProperty method is async and returns a JSHandle. It fetches a single property from the referenced object. It takes a parameter propertyName of type string which is the property to get.

JSHandle.jsonValue method

The jsonValue method is async and returns a Serializable value. It returns a JSON representation of the object. If the object has a toJSON function, it will not be called. The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an error if the object has circular references.

JSHandle.evaluate example with DOM node

Example: const tweetHandle = await page.$('.tweet .retweets'); expect(await tweetHandle.evaluate(node => node.innerText)).toBe('10 retweets');

JSHandle.getProperties example

Example: const handle = await page.evaluateHandle(() => ({ window, document })); const properties = await handle.getProperties(); const windowHandle = properties.get('window'); const documentHandle = properties.get('document'); await handle.dispose();

Give your agent this brain