|
| typing.Any | evaluate (self, str expression, typing.Optional[typing.Any] arg=None) |
| |
| "JSHandle" | evaluate_handle (self, str expression, typing.Optional[typing.Any] arg=None) |
| |
| "JSHandle" | get_property (self, str property_name) |
| |
| typing.Dict[str, "JSHandle"] | get_properties (self) |
| |
| typing.Optional["ElementHandle"] | as_element (self) |
| |
| None | dispose (self) |
| |
| typing.Any | json_value (self) |
| |
| None | __init__ (self, Any impl_obj) |
| |
|
str | __str__ (self) |
| |
| None | on (self, Any event, Any f) |
| |
| None | once (self, Any event, Any f) |
| |
| None | remove_listener (self, Any event, Any f) |
| |
|
str | __repr__ (self) |
| |
|
|
Callable[..., None] | _wrap_handler (self, Union[Callable[..., Any], Any] handler) |
| |
|
| _loop |
| |
|
| _impl_obj |
| |
◆ as_element()
| typing.Optional["ElementHandle"] playwright.async_api._generated.JSHandle.as_element |
( |
|
self | ) |
|
JSHandle.as_element
Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`.
Returns
-------
Union[ElementHandle, None]
◆ dispose()
| None playwright.async_api._generated.JSHandle.dispose |
( |
|
self | ) |
|
JSHandle.dispose
The `jsHandle.dispose` method stops referencing the element handle.
◆ evaluate()
| typing.Any playwright.async_api._generated.JSHandle.evaluate |
( |
|
self, |
|
|
str |
expression, |
|
|
typing.Optional[typing.Any] |
arg = None |
|
) |
| |
JSHandle.evaluate
Returns the return value of `expression`.
This method passes this handle as the first argument to `expression`.
If `expression` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its
value.
**Usage**
```py
tweet_handle = await page.query_selector(\".tweet .retweets\")
assert await tweet_handle.evaluate(\"node => node.innerText\") == \"10 retweets\"
```
Parameters
----------
expression : str
JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the
function is automatically invoked.
arg : Union[Any, None]
Optional argument to pass to `expression`.
Returns
-------
Any
◆ evaluate_handle()
| "JSHandle" playwright.async_api._generated.JSHandle.evaluate_handle |
( |
|
self, |
|
|
str |
expression, |
|
|
typing.Optional[typing.Any] |
arg = None |
|
) |
| |
JSHandle.evaluate_handle
Returns the return value of `expression` as a `JSHandle`.
This method passes this handle as the first argument to `expression`.
The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle`
returns `JSHandle`.
If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would
wait for the promise to resolve and return its value.
See `page.evaluate_handle()` for more details.
Parameters
----------
expression : str
JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the
function is automatically invoked.
arg : Union[Any, None]
Optional argument to pass to `expression`.
Returns
-------
JSHandle
◆ get_properties()
| typing.Dict[str, "JSHandle"] playwright.async_api._generated.JSHandle.get_properties |
( |
|
self | ) |
|
JSHandle.get_properties
The method returns a map with **own property names** as keys and JSHandle instances for the property values.
**Usage**
```py
handle = await page.evaluate_handle(\"({ window, document })\")
properties = await handle.get_properties()
window_handle = properties.get(\"window\")
document_handle = properties.get(\"document\")
await handle.dispose()
```
Returns
-------
Dict[str, JSHandle]
◆ get_property()
| "JSHandle" playwright.async_api._generated.JSHandle.get_property |
( |
|
self, |
|
|
str |
property_name |
|
) |
| |
JSHandle.get_property
Fetches a single property from the referenced object.
Parameters
----------
property_name : str
property to get
Returns
-------
JSHandle
◆ json_value()
| typing.Any playwright.async_api._generated.JSHandle.json_value |
( |
|
self | ) |
|
JSHandle.json_value
Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
**NOTE** 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.
Returns
-------
Any
The documentation for this class was generated from the following file:
- docs/help/help-venv/lib/python3.12/site-packages/playwright/async_api/_generated.py