From 68a09ca353040ccd59d115967748c9c14ae42d6d Mon Sep 17 00:00:00 2001 From: Daofeng Wu Date: Wed, 5 Feb 2025 20:00:04 +0900 Subject: [PATCH] fix(playwright): add context manager methods --- npiai/core/browser/_playwright.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/npiai/core/browser/_playwright.py b/npiai/core/browser/_playwright.py index 13c41af..b42bf8e 100644 --- a/npiai/core/browser/_playwright.py +++ b/npiai/core/browser/_playwright.py @@ -212,3 +212,10 @@ async def stop(self): await self.playwright.stop() self.ready = False self.closed = True + + async def __aenter__(self): + await self.start() + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.stop()