MCPcopy Index your code
hub / github.com/microsoft/playwright-python / expect_console_message

Method expect_console_message

playwright/async_api/_generated.py:12899–12929  ·  view source on GitHub ↗

Page.expect_console_message Performs action and waits for a `ConsoleMessage` to be logged by in the page. If predicate is provided, it passes `ConsoleMessage` value into the `predicate` function and waits for `predicate(message)` to return a truthy value. Will throw an error

(
        self,
        predicate: typing.Optional[typing.Callable[["ConsoleMessage"], bool]] = None,
        *,
        timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
    )

Source from the content-addressed store, hash-verified

12897 )
12898
12899 def expect_console_message(
12900 self,
12901 predicate: typing.Optional[typing.Callable[["ConsoleMessage"], bool]] = None,
12902 *,
12903 timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
12904 ) -> AsyncEventContextManager["ConsoleMessage"]:
12905 """Page.expect_console_message
12906
12907 Performs action and waits for a `ConsoleMessage` to be logged by in the page. If predicate is provided, it passes
12908 `ConsoleMessage` value into the `predicate` function and waits for `predicate(message)` to return a truthy value.
12909 Will throw an error if the page is closed before the `page.on('console')` event is fired.
12910
12911 Parameters
12912 ----------
12913 predicate : Union[Callable[[ConsoleMessage], bool], None]
12914 Receives the `ConsoleMessage` object and resolves to truthy value when the waiting should resolve.
12915 timeout : Union[float, None]
12916 Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The
12917 default value can be changed by using the `browser_context.set_default_timeout()`.
12918
12919 Returns
12920 -------
12921 EventContextManager[ConsoleMessage]
12922 """
12923
12924 return AsyncEventContextManager(
12925 self._impl_obj.expect_console_message(
12926 predicate=self._wrap_handler(predicate),
12927 timeout=to_milliseconds(timeout),
12928 ).future
12929 )
12930
12931 def expect_download(
12932 self,

Callers 1

Calls 3

to_millisecondsFunction · 0.90
_wrap_handlerMethod · 0.45

Tested by

no test coverage detected