From aedaeb4433c5721968aa6be2948f198679bb6867 Mon Sep 17 00:00:00 2001 From: LawyZheng Date: Sat, 21 Sep 2024 09:30:34 +0800 Subject: [PATCH] skip invisible iframe (#870) --- skyvern/webeye/scraper/scraper.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/skyvern/webeye/scraper/scraper.py b/skyvern/webeye/scraper/scraper.py index 85fa31f2..790ba816 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}')"