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

Method expect_request

playwright/_impl/_page.py:1300–1321  ·  view source on GitHub ↗
(
        self,
        urlOrPredicate: URLMatchRequest,
        timeout: float = None,
    )

Source from the content-addressed store, hash-verified

1298 return self.expect_event(Page.Events.Popup, predicate, timeout)
1299
1300 def expect_request(
1301 self,
1302 urlOrPredicate: URLMatchRequest,
1303 timeout: float = None,
1304 ) -> EventContextManagerImpl[Request]:
1305 def my_predicate(request: Request) -> Union[bool, Awaitable[bool]]:
1306 if not callable(urlOrPredicate):
1307 return url_matches(
1308 self._browser_context._base_url,
1309 request.url,
1310 urlOrPredicate,
1311 )
1312 return urlOrPredicate(request)
1313
1314 trimmed_url = trim_url(urlOrPredicate)
1315 log_line = f"waiting for request {trimmed_url}" if trimmed_url else None
1316 return self._expect_event(
1317 Page.Events.Request,
1318 predicate=my_predicate,
1319 timeout=timeout,
1320 log_line=log_line,
1321 )
1322
1323 def expect_request_finished(
1324 self,

Callers

nothing calls this directly

Calls 2

_expect_eventMethod · 0.95
trim_urlFunction · 0.85

Tested by

no test coverage detected