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

Method expect_file_chooser

playwright/async_api/_generated.py:12963–12993  ·  view source on GitHub ↗

Page.expect_file_chooser Performs action and waits for a new `FileChooser` to be created. If predicate is provided, it passes `FileChooser` value into the `predicate` function and waits for `predicate(fileChooser)` to return a truthy value. Will throw an error if the page is

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

Source from the content-addressed store, hash-verified

12961 )
12962
12963 def expect_file_chooser(
12964 self,
12965 predicate: typing.Optional[typing.Callable[["FileChooser"], bool]] = None,
12966 *,
12967 timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
12968 ) -> AsyncEventContextManager["FileChooser"]:
12969 """Page.expect_file_chooser
12970
12971 Performs action and waits for a new `FileChooser` to be created. If predicate is provided, it passes `FileChooser`
12972 value into the `predicate` function and waits for `predicate(fileChooser)` to return a truthy value. Will throw an
12973 error if the page is closed before the file chooser is opened.
12974
12975 Parameters
12976 ----------
12977 predicate : Union[Callable[[FileChooser], bool], None]
12978 Receives the `FileChooser` object and resolves to truthy value when the waiting should resolve.
12979 timeout : Union[float, None]
12980 Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The
12981 default value can be changed by using the `browser_context.set_default_timeout()`.
12982
12983 Returns
12984 -------
12985 EventContextManager[FileChooser]
12986 """
12987
12988 return AsyncEventContextManager(
12989 self._impl_obj.expect_file_chooser(
12990 predicate=self._wrap_handler(predicate),
12991 timeout=to_milliseconds(timeout),
12992 ).future
12993 )
12994
12995 def expect_navigation(
12996 self,

Callers

nothing calls this directly

Calls 3

to_millisecondsFunction · 0.90
_wrap_handlerMethod · 0.45

Tested by

no test coverage detected