示例#1
0
 def frame(self, name: str = None, url: URLMatch = None) -> Optional[Frame]:
     matcher = URLMatcher(url) if url else None
     for frame in self._frames:
         if name and frame.name == name:
             return frame
         if url and matcher and matcher.matches(frame.url):
             return frame
     return None
示例#2
0
 async def waitForNavigation(
     self,
     timeout: int = None,
     waitUntil: DocumentLoadState = "load",
     url: URLMatch = None,
 ) -> Optional[Response]:
     wait_helper = self._setup_navigation_wait_helper(timeout)
     matcher = URLMatcher(url) if url else None
     event = await wait_helper.wait_for_event(
         self._event_emitter,
         "navigated",
         lambda event: not matcher or matcher.matches(event["url"]),
     )
     if "newDocument" in event and "request" in event["newDocument"]:
         request = from_channel(event["newDocument"]["request"])
         return await request.response()
     if "error" in event:
         raise Error(event["error"])
     return None