Skip to content

Automate browser based workflows with AI

cache replay bug - if click locator is not found, fallback to us llm to find the locator (#4079)

Shuchang Zheng51b968d0a260
diff --git a/skyvern/core/script_generations/real_skyvern_page_ai.py b/skyvern/core/script_generations/real_skyvern_page_ai.py
index b26ca8224..34ae0a282 100644
--- a/skyvern/core/script_generations/real_skyvern_page_ai.py
+++ b/skyvern/core/script_generations/real_skyvern_page_ai.py
@@ -50,8 +50,12 @@ UPLOAD_GOAL = """- The intention to upload a file: {intention}.
async def _get_element_id_by_selector(selector: str, page: Page) -> str | None:
- locator = page.locator(selector)
- element_id = await locator.get_attribute("unique_id")
+ try:
+ locator = page.locator(selector)
+ element_id = await locator.get_attribute("unique_id", timeout=settings.BROWSER_ACTION_TIMEOUT_MS)
+ except Exception:
+ LOG.exception("Failed to get element id by selector", selector=selector)
+ return None
return element_id