File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 22import time
33from typing import Optional , Union
44
5+ from playwright ._impl ._errors import TargetClosedError
56from playwright .async_api import CDPSession , Page
67from pydantic import BaseModel
78
@@ -75,14 +76,11 @@ async def ensure_injection(self):
7576 await self ._page .evaluate (_INJECTION_SCRIPT )
7677 # Ensure that the script is injected on future navigations
7778 await self ._page .add_init_script (_INJECTION_SCRIPT )
78- except Exception as e :
79- if "Execution context was destroyed" in str (e ):
80- self ._stagehand .logger .warning (
81- f"ensure_injection failed (page may be navigating): { e } " ,
82- category = "page" ,
83- )
84- else :
85- raise
79+ except TargetClosedError as e :
80+ self ._stagehand .logger .warning (
81+ f"ensure_injection failed (page may be navigating): { e } " ,
82+ category = "page" ,
83+ )
8684
8785 async def goto (
8886 self ,
You can’t perform that action at this time.
0 commit comments