🥅 Add error handling for UI setup to improve robustness (#4)

This commit is contained in:
2025-12-09 00:04:59 +01:00
committed by GitHub
parent 4989cab2d9
commit 31c115ed5a

View File

@@ -233,6 +233,7 @@ class FlagRenderer:
return new_path return new_path
async def _setup_ui(self, page: playwright.async_api.Page) -> None: async def _setup_ui(self, page: playwright.async_api.Page) -> None:
try:
side_panel_btn = page.locator(SITE_PANEL_BTN_XPATH) side_panel_btn = page.locator(SITE_PANEL_BTN_XPATH)
await side_panel_btn.click(timeout=CLICK_TIMEOUT) await side_panel_btn.click(timeout=CLICK_TIMEOUT)
@@ -246,6 +247,9 @@ class FlagRenderer:
theater_mode_btn = page.get_by_text(THEATER_MODE_TEXT) theater_mode_btn = page.get_by_text(THEATER_MODE_TEXT)
await theater_mode_btn.click(timeout=CLICK_TIMEOUT, force=True) await theater_mode_btn.click(timeout=CLICK_TIMEOUT, force=True)
except playwright.async_api.TimeoutError:
logger.exception("Failed to setup the UI")
logger.debug("Page content: %s", await page.content())
@asynccontextmanager @asynccontextmanager
async def render(self, flag: "Flag") -> AsyncIterator[Path]: async def render(self, flag: "Flag") -> AsyncIterator[Path]: