MCPcopy Index your code
hub / github.com/microsoft/playwright-python / _export_har

Method _export_har

playwright/_impl/_tracing.py:247–281  ·  view source on GitHub ↗
(self, har_id: str)

Source from the content-addressed store, hash-verified

245 await self._export_har(har_id)
246
247 async def _export_har(self, har_id: str) -> None:
248 params = self._har_recorders.pop(har_id, None)
249 if not params:
250 return
251 is_local = not self._connection.is_remote
252 is_zip = params["path"].endswith(".zip")
253
254 if is_local:
255 result = await self._channel.send_return_as_dict(
256 "harExport", None, {"harId": har_id, "mode": "entries"}
257 )
258 if not is_zip:
259 # Server wrote HAR and resources to the user's chosen paths.
260 return
261 await self._connection.local_utils.zip(
262 {
263 "zipFile": params["path"],
264 "entries": result["entries"],
265 "mode": "write",
266 "includeSources": False,
267 }
268 )
269 return
270
271 result = await self._channel.send_return_as_dict(
272 "harExport", None, {"harId": har_id, "mode": "archive"}
273 )
274 artifact = cast(Artifact, from_channel(result["artifact"]))
275 if is_zip:
276 await artifact.save_as(params["path"])
277 await artifact.delete()
278 return
279 # Uncompressed har is not supported in thin clients
280 await artifact.save_as(params["path"] + ".tmp")
281 await artifact.delete()

Callers 2

_export_all_harsMethod · 0.95
stop_harMethod · 0.95

Calls 5

from_channelFunction · 0.90
send_return_as_dictMethod · 0.80
zipMethod · 0.80
save_asMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected