Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fixed nested iframe scroll bounds

Gregor Žunič3763275e1c5a
diff --git a/browser_use/dom/service.py b/browser_use/dom/service.py
index f56728b74..aae4639e5 100644
--- a/browser_use/dom/service.py
+++ b/browser_use/dom/service.py
@@ -193,6 +193,7 @@ class DomService:
):
iframe_bounds = frame.snapshot_node.bounds
+ # negate the values added in `_construct_enhanced_node`
current_bounds.x += iframe_bounds.x
current_bounds.y += iframe_bounds.y
@@ -218,6 +219,10 @@ class DomService:
if not frame_intersects:
return False
+ # negate the values added in `_construct_enhanced_node`
+ current_bounds.x -= frame.snapshot_node.scrollRects.x
+ current_bounds.y -= frame.snapshot_node.scrollRects.y
+
# If we reach here, element is visible in main viewport and all containing iframes
return True