Skip to content

Automate browser based workflows with AI

skip invisible iframe (#870)

LawyZhengaedaeb4433c5
diff --git a/skyvern/webeye/scraper/scraper.py b/skyvern/webeye/scraper/scraper.py
index 85fa31f23..790ba8161 100644
--- a/skyvern/webeye/scraper/scraper.py
+++ b/skyvern/webeye/scraper/scraper.py
@@ -249,6 +249,19 @@ async def get_frame_text(iframe: Frame) -> str:
if child_frame.is_detached():
continue
+ try:
+ child_frame_element = await child_frame.frame_element()
+ except Exception:
+ LOG.warning(
+ "Unable to get child_frame_element",
+ exc_info=True,
+ )
+ continue
+
+ # it will get stuck when we `frame.evaluate()` on an invisible iframe
+ if not await child_frame_element.is_visible():
+ continue
+
text += await get_frame_text(child_frame)
return text
@@ -341,6 +354,10 @@ async def get_interactable_element_tree_in_frame(
)
continue
+ # it will get stuck when we `frame.evaluate()` on an invisible iframe
+ if not await frame_element.is_visible():
+ continue
+
unique_id = await frame_element.get_attribute("unique_id")
frame_js_script = f"() => buildTreeFromBody('{unique_id}')"