async def waitForEvent(self,
                        event: str,
                        predicate: Callable[[Any], bool] = None,
                        timeout: int = None) -> Any:
     if timeout is None:
         timeout = self._timeout_settings.timeout()
     wait_helper = WaitHelper(self._loop)
     wait_helper.reject_on_timeout(
         timeout, f'Timeout while waiting for event "${event}"')
     if event != BrowserContext.Events.Close:
         wait_helper.reject_on_event(self, BrowserContext.Events.Close,
                                     Error("Context closed"))
     return await wait_helper.wait_for_event(self, event, predicate)
Beispiel #2
0
 def _setup_navigation_wait_helper(self, timeout: int = None) -> WaitHelper:
     wait_helper = WaitHelper(self._loop)
     wait_helper.reject_on_event(
         self._page, "close", Error("Navigation failed because page was closed!")
     )
     wait_helper.reject_on_event(
         self._page, "crash", Error("Navigation failed because page crashed!")
     )
     wait_helper.reject_on_event(
         self._page,
         "framedetached",
         Error("Navigating frame was detached!"),
         lambda frame: frame == self,
     )
     if timeout is None:
         timeout = self._page._timeout_settings.navigation_timeout()
     wait_helper.reject_on_timeout(timeout, f"Timeout {timeout}ms exceeded.")
     return wait_helper
Beispiel #3
0
 async def waitForEvent(self,
                        event: str,
                        predicate: Callable[[Any], bool] = None,
                        timeout: int = None) -> Any:
     if timeout is None:
         timeout = cast(Any, self._parent)._timeout_settings.timeout()
     wait_helper = WaitHelper(self._loop)
     wait_helper.reject_on_timeout(
         timeout, f'Timeout while waiting for event "${event}"')
     if event != WebSocket.Events.Close:
         wait_helper.reject_on_event(self, WebSocket.Events.Close,
                                     Error("Socket closed"))
     if event != WebSocket.Events.Error:
         wait_helper.reject_on_event(self, WebSocket.Events.Error,
                                     Error("Socket error"))
     wait_helper.reject_on_event(self._parent, "close",
                                 Error("Page closed"))
     return await wait_helper.wait_for_event(self, event, predicate)