Пример #1
0
 async def remove_browser(self, browser: Browser) -> None:
     """Close browser and remove all references."""
     del self.managed_browsers[browser]
     try:
         browser._connection._closeCallback = None
         await asyncio.wait_for(browser.close(), timeout=5)
     except Exception:
         self.logger.warning(f"Could not properly close browser.")
Пример #2
0
 async def _shutdown_browser(self, browser: Browser) -> None:
     """Close browser and remove all references."""
     logger.info(f"Shutting down browser: {browser}")
     # remove all pages from the browser.
     for page in await browser.pages():
         await self._close_page(page)
     try:
         browser._connection._closeCallback = None
         await asyncio.wait_for(browser.close(), timeout=2)
     except asyncio.TimeoutError:
         logger.warning(f"Could not properly close browser: {browser}")
     del self.browsers[browser]
Пример #3
0
 async def _shutdown_browser(self, browser: Browser) -> None:
     """Close browser and remove all references."""
     logger.info(f"Removing browser: {browser}")
     # remove all pages from the browser.
     for page in await browser.pages():
         await self._close_page(page)
     # disable self.__on_connection_close
     browser._connection._closeCallback = None
     # attempt to properly close browser.
     try:
         await asyncio.wait_for(browser.close(), timeout=2)
     except asyncio.TimeoutError:
         pass
     del self.browsers[browser]
Пример #4
0
def exit_if_wrong_url(page: Page, browser: Browser, url_to_check: str):
    if not page.url == url_to_check:
        __logger.error('Exit due to Wrong URL!')
        browser.close()
        exit()