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

Method expect_download

playwright/async_api/_generated.py:12931–12961  ·  view source on GitHub ↗

Page.expect_download Performs action and waits for a new `Download`. If predicate is provided, it passes `Download` value into the `predicate` function and waits for `predicate(download)` to return a truthy value. Will throw an error if the page is closed before the download

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

Source from the content-addressed store, hash-verified

12929 )
12930
12931 def expect_download(
12932 self,
12933 predicate: typing.Optional[typing.Callable[["Download"], bool]] = None,
12934 *,
12935 timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
12936 ) -> AsyncEventContextManager["Download"]:
12937 """Page.expect_download
12938
12939 Performs action and waits for a new `Download`. If predicate is provided, it passes `Download` value into the
12940 `predicate` function and waits for `predicate(download)` to return a truthy value. Will throw an error if the page
12941 is closed before the download event is fired.
12942
12943 Parameters
12944 ----------
12945 predicate : Union[Callable[[Download], bool], None]
12946 Receives the `Download` object and resolves to truthy value when the waiting should resolve.
12947 timeout : Union[float, None]
12948 Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The
12949 default value can be changed by using the `browser_context.set_default_timeout()`.
12950
12951 Returns
12952 -------
12953 EventContextManager[Download]
12954 """
12955
12956 return AsyncEventContextManager(
12957 self._impl_obj.expect_download(
12958 predicate=self._wrap_handler(predicate),
12959 timeout=to_milliseconds(timeout),
12960 ).future
12961 )
12962
12963 def expect_file_chooser(
12964 self,

Callers

nothing calls this directly

Calls 3

to_millisecondsFunction · 0.90
_wrap_handlerMethod · 0.45

Tested by

no test coverage detected