Raise screenshot error earlier when page is closed (#1108)

This commit is contained in:
Shuchang Zheng
2024-11-01 10:43:24 -07:00
committed by GitHub
parent 252ea7922e
commit 690dd4c2e8
2 changed files with 22 additions and 0 deletions

View File

@@ -39,6 +39,8 @@ class SkyvernFrame:
file_path: str | None = None,
timeout: float = SettingsManager.get_settings().BROWSER_LOADING_TIMEOUT_MS,
) -> bytes:
if page.is_closed():
raise FailedToTakeScreenshot(error_message="Page is closed")
try:
await page.wait_for_load_state(timeout=SettingsManager.get_settings().BROWSER_LOADING_TIMEOUT_MS)
LOG.debug("Page is fully loaded, agent is about to take screenshots")