|
| None | on (self, Literal["close"] event, typing.Callable[["Worker"], "typing.Union[typing.Awaitable[None], None]"] f) |
| |
| None | on (self, Literal["console"] event, typing.Callable[["ConsoleMessage"], "typing.Union[typing.Awaitable[None], None]"] f) |
| |
| None | on (self, str event, typing.Callable[..., typing.Union[typing.Awaitable[None], None]] f) |
| |
| None | once (self, Literal["close"] event, typing.Callable[["Worker"], "typing.Union[typing.Awaitable[None], None]"] f) |
| |
| None | once (self, Literal["console"] event, typing.Callable[["ConsoleMessage"], "typing.Union[typing.Awaitable[None], None]"] f) |
| |
| None | once (self, str event, typing.Callable[..., typing.Union[typing.Awaitable[None], None]] f) |
| |
| str | url (self) |
| |
| typing.Any | evaluate (self, str expression, typing.Optional[typing.Any] arg=None) |
| |
| "JSHandle" | evaluate_handle (self, str expression, typing.Optional[typing.Any] arg=None) |
| |
| AsyncEventContextManager | expect_event (self, str event, typing.Optional[typing.Callable] predicate=None, *typing.Optional[float] timeout=None) |
| |
| None | __init__ (self, Any impl_obj) |
| |
|
str | __str__ (self) |
| |
| None | remove_listener (self, Any event, Any f) |
| |
|
str | __repr__ (self) |
| |
|
|
Callable[..., None] | _wrap_handler (self, Union[Callable[..., Any], Any] handler) |
| |
|
| _loop |
| |
|
| _impl_obj |
| |
◆ evaluate()
| typing.Any playwright.async_api._generated.Worker.evaluate |
( |
|
self, |
|
|
str |
expression, |
|
|
typing.Optional[typing.Any] |
arg = None |
|
) |
| |
Worker.evaluate
Returns the return value of `expression`.
If the function passed to the `worker.evaluate()` returns a [Promise], then `worker.evaluate()`
would wait for the promise to resolve and return its value.
If the function passed to the `worker.evaluate()` returns a non-[Serializable] value, then
`worker.evaluate()` returns `undefined`. Playwright also supports transferring some additional values that
are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
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.Worker.evaluate_handle |
( |
|
self, |
|
|
str |
expression, |
|
|
typing.Optional[typing.Any] |
arg = None |
|
) |
| |
Worker.evaluate_handle
Returns the return value of `expression` as a `JSHandle`.
The only difference between `worker.evaluate()` and `worker.evaluate_handle()` is that
`worker.evaluate_handle()` returns `JSHandle`.
If the function passed to the `worker.evaluate_handle()` returns a [Promise], then
`worker.evaluate_handle()` would wait for the promise to resolve and return its value.
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
◆ expect_event()
| AsyncEventContextManager playwright.async_api._generated.Worker.expect_event |
( |
|
self, |
|
|
str |
event, |
|
|
typing.Optional[typing.Callable] |
predicate = None, |
|
|
*typing.Optional[float] |
timeout = None |
|
) |
| |
Worker.expect_event
Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
value. Will throw an error if the page is closed before the event is fired. Returns the event data value.
**Usage**
```py
async with worker.expect_event(\"console\") as event_info:
await worker.evaluate(\"console.log(42)\")
message = await event_info.value
```
Parameters
----------
event : str
Event name, same one typically passed into `*.on(event)`.
predicate : Union[Callable, None]
Receives the event data and resolves to truthy value when the waiting should resolve.
timeout : Union[float, None]
Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The
default value can be changed by using the `browser_context.set_default_timeout()`.
Returns
-------
EventContextManager
◆ on() [1/3]
| None playwright.async_api._generated.Worker.on |
( |
|
self, |
|
|
Literal["close"] |
event, |
|
|
typing.Callable[["Worker"], "typing.Union[typing.Awaitable[None], None]"] |
f |
|
) |
| |
◆ on() [2/3]
| None playwright.async_api._generated.Worker.on |
( |
|
self, |
|
|
Literal["console"] |
event, |
|
|
typing.Callable[
["ConsoleMessage"], "typing.Union[typing.Awaitable[None], None]"
] |
f |
|
) |
| |
◆ on() [3/3]
| None playwright.async_api._generated.Worker.on |
( |
|
self, |
|
|
str |
event, |
|
|
typing.Callable[..., typing.Union[typing.Awaitable[None], None]] |
f |
|
) |
| |
◆ once() [1/3]
| None playwright.async_api._generated.Worker.once |
( |
|
self, |
|
|
Literal["close"] |
event, |
|
|
typing.Callable[["Worker"], "typing.Union[typing.Awaitable[None], None]"] |
f |
|
) |
| |
◆ once() [2/3]
| None playwright.async_api._generated.Worker.once |
( |
|
self, |
|
|
Literal["console"] |
event, |
|
|
typing.Callable[
["ConsoleMessage"], "typing.Union[typing.Awaitable[None], None]"
] |
f |
|
) |
| |
◆ once() [3/3]
| None playwright.async_api._generated.Worker.once |
( |
|
self, |
|
|
str |
event, |
|
|
typing.Callable[..., typing.Union[typing.Awaitable[None], None]] |
f |
|
) |
| |
◆ url()
| str playwright.async_api._generated.Worker.url |
( |
|
self | ) |
|
Worker.url
Returns
-------
str
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