async def wait_for_event(self,
                          event: str,
                          predicate: Callable[[Any], bool] = None,
                          timeout: float = 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)
Example #2
0
 async def wait_for_event(
     self, event: str, predicate: Callable = None, timeout: float = 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 != Page.Events.Crash:
         wait_helper.reject_on_event(self, Page.Events.Crash, Error("Page crashed"))
     if event != Page.Events.Close:
         wait_helper.reject_on_event(self, Page.Events.Close, Error("Page closed"))
     return await wait_helper.wait_for_event(self, event, predicate)
Example #3
0
 def expect_event(
     self,
     event: str,
     predicate: Callable = None,
     timeout: float = None,
 ) -> EventContextManagerImpl:
     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"))
     wait_helper.wait_for_event(self, event, predicate)
     return EventContextManagerImpl(wait_helper.result())
Example #4
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)
Example #5
0
 def expect_event(
     self,
     event: str,
     predicate: Callable = None,
     timeout: float = None,
 ) -> EventContextManagerImpl:
     if timeout is None:
         timeout = self._timeout_settings.timeout()
     wait_helper = WaitHelper(self, f"page.expect_event({event})")
     wait_helper.reject_on_timeout(
         timeout, f'Timeout while waiting for event "{event}"'
     )
     if event != Page.Events.Crash:
         wait_helper.reject_on_event(self, Page.Events.Crash, Error("Page crashed"))
     if event != Page.Events.Close:
         wait_helper.reject_on_event(self, Page.Events.Close, Error("Page closed"))
     wait_helper.wait_for_event(self, event, predicate)
     return EventContextManagerImpl(wait_helper.result())
 def _setup_navigation_wait_helper(self,
                                   timeout: float = 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
Example #7
0
 def expect_event(
     self,
     event: str,
     predicate: Callable = None,
     timeout: float = None,
 ) -> EventContextManagerImpl:
     if timeout is None:
         timeout = cast(Any, self._parent)._timeout_settings.timeout()
     wait_helper = WaitHelper(self, f"web_socket.expect_event({event})")
     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"))
     wait_helper.wait_for_event(self, event, predicate)
     return EventContextManagerImpl(wait_helper.result())