fix invisible iframe scraping (#1723)

This commit is contained in:
Shuchang Zheng
2025-02-05 13:33:45 +08:00
committed by GitHub
parent f40f7600f7
commit 6f3dcd13b8
2 changed files with 32 additions and 31 deletions

View File

@@ -470,19 +470,17 @@ async def get_interactable_element_tree_in_frame(
try:
frame_element = await frame.frame_element()
# 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")
except Exception:
LOG.warning(
"Unable to get frame_element",
"Unable to get unique_id from frame_element",
exc_info=True,
)
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}')"
await SkyvernFrame.evaluate(frame=frame, expression=JS_FUNCTION_DEFS)