-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Implement object handles #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The |
This patch: - teaches `page.evaluate` to accept ElementHandles as parameters - removes `ElementHandle.evaluate` method since it's not needed any more References puppeteer#382
This patch: - teaches `page.evaluate` to accept ElementHandles as parameters - removes `ElementHandle.evaluate` method since it's not needed any more References #382
This patch: - gives meaningful names to doclint tests - supports classes inheritance in documentation linter. When class A extends class B, all methods of class B are added to documentation of class A. This is a prerequisite for Object Handles: ElementHandle will be extending ObjectHandle. References puppeteer#382
This patch: - gives meaningful names to doclint tests - supports classes inheritance in documentation linter. When class A extends class B, all methods of class B are added to documentation of class A. This is a prerequisite for Object Handles: ElementHandle will be extending ObjectHandle. References #382
This patch: - introduces ExecutionContext class that incapsulates javascript execution context. An examples of execution contexts are workers and frames - introduces ObjectHandle that holds a references to the javascript object in ExecutionContext - inherits ElementHandle from ObjectHandle Fixes puppeteer#382.
This patch: - introduces ExecutionContext class that incapsulates javascript execution context. An examples of execution contexts are workers and frames - introduces JSHandle that holds a references to the javascript object in ExecutionContext - inherits ElementHandle from JSHandle Fixes #382.
How does one obtain the property value from the JSHandle? const totalCostElement = await page.$('.review-payment__cost-breakdown strong');
const totalCostElementTextContent = await totalCostElement.getProperty('textContent'); This returns |
Turns out you simply need to use This API is rather odd. Whats the reason for JSHandle abstraction in the first place? |
@aslushnikov let's remove toString before it is misused broadly. I don't remember reviewing it btw, I remember renaming old |
Whats the correct way to get the property value? |
@gajus it's |
This patch: - updates JSHandle.toString to make a nicer description for primitives - excludes JSHandle.toString from documentation to avoid its abuse References puppeteer#382
This description makes it in no way clear that |
This patch: - updates JSHandle.toString to make a nicer description for primitives - excludes JSHandle.toString from documentation to avoid its abuse References #382
@gajus If you want a value of particular object property, you'd need to use both const navigatorHandle = await page.evaluateHandle(() => window.navigator);
const uaHandle = await navigatorHandle.getProperty('navigator');
const ua = await uaHandle.jsonValue(); Alternatively, you can use the evaluate method: const navigatorHandle = await page.evaluateHandle(() => window.navigator);
const ua = await page.evaluate(obj => obj.userAgent, navigatorHandle); |
…#993) This patch: - updates JSHandle.toString to make a nicer description for primitives - excludes JSHandle.toString from documentation to avoid its abuse References puppeteer#382
When do I need to call |
page.object(func)
that returns a newObjectHandle
type.ObjectHandle.json()
that would return result similar to presentpage.evaluate
. That will allow access to the raw object handlers for non-trivial operations.ElementHandle
fromObjectHandle
if possibleevaluateOn
on the objectsThe text was updated successfully, but these errors were encountered: