| 1330 | ) |
| 1331 | |
| 1332 | def expect_response( |
| 1333 | self, |
| 1334 | urlOrPredicate: URLMatchResponse, |
| 1335 | timeout: float = None, |
| 1336 | ) -> EventContextManagerImpl[Response]: |
| 1337 | def my_predicate(request: Response) -> Union[bool, Awaitable[bool]]: |
| 1338 | if not callable(urlOrPredicate): |
| 1339 | return url_matches( |
| 1340 | self._browser_context._base_url, |
| 1341 | request.url, |
| 1342 | urlOrPredicate, |
| 1343 | ) |
| 1344 | return urlOrPredicate(request) |
| 1345 | |
| 1346 | trimmed_url = trim_url(urlOrPredicate) |
| 1347 | log_line = f"waiting for response {trimmed_url}" if trimmed_url else None |
| 1348 | return self._expect_event( |
| 1349 | Page.Events.Response, |
| 1350 | predicate=my_predicate, |
| 1351 | timeout=timeout, |
| 1352 | log_line=log_line, |
| 1353 | ) |
| 1354 | |
| 1355 | def expect_websocket( |
| 1356 | self, |