async def close(self) -> None: try: for har_id, params in self._har_recorders.items(): har = cast( Artifact, from_channel(await self._channel.send("harExport", {"harId": har_id})), ) # Server side will compress artifact if content is attach or if file is .zip. is_compressed = params.get( "content") == "attach" or params["path"].endswith(".zip") need_compressed = params["path"].endswith(".zip") if is_compressed and not need_compressed: tmp_path = params["path"] + ".tmp" await har.save_as(tmp_path) await self._connection.local_utils.har_unzip( zipFile=tmp_path, harFile=params["path"]) else: await har.save_as(params["path"]) await har.delete() await self._channel.send("close") await self._closed_future except Exception as e: if not is_safe_close_error(e): raise e
async def close(self) -> None: try: await self._channel.send("close") await self._closed_future except Exception as e: if not is_safe_close_error(e): raise e
async def close(self, runBeforeUnload: bool = None) -> None: try: await self._channel.send("close", locals_to_params(locals())) if self._owned_context: await self._owned_context.close() except Exception as e: if not is_safe_close_error(e): raise e
async def close(self) -> None: if self._is_closed_or_closing: return self._is_closed_or_closing = True try: await self._channel.send("close") except Exception as e: if not is_safe_close_error(e): raise e
async def close(self) -> None: if self._is_closed_or_closing: return self._is_closed_or_closing = True try: await self._channel.send("close") except Exception as e: if not is_safe_close_error(e): raise e if self._is_connected_over_websocket: await self._connection.stop_async()
async def close(self) -> None: try: if self._options.get("recordHar"): har = cast(Artifact, from_channel(await self._channel.send("harExport"))) await har.save_as( cast(Dict[str, str], self._options["recordHar"])["path"]) await har.delete() await self._channel.send("close") await self._closed_future except Exception as e: if not is_safe_close_error(e): raise e
async def body(self) -> bytes: try: result = await self._request._channel.send_return_as_dict( "fetchResponseBody", { "fetchUid": self._fetch_uid(), }, ) if result is None: raise Error("Response has been disposed") return base64.b64decode(result["binary"]) except Error as exc: if is_safe_close_error(exc): raise Error("Response has been disposed") raise exc