Skip to content

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

Fix cross-origin iframe DOM retrieval (#1965)

Nick Sweeting5aa62c11136e
diff --cc browser_use/dom/service.py
index b35c5a4eb,d31f1673f..cebdade18
--- a/browser_use/dom/service.py
+++ b/browser_use/dom/service.py
@@@ -16,12 -16,49 +16,48 @@@ from browser_use.dom.views import
)
from browser_use.utils import time_execution_async
-
-@dataclass
-class ViewportInfo:
- width: int
- height: int
+# @dataclass
+# class ViewportInfo:
+# width: int
+# height: int
+ @dataclass
+ class PageFrameEvaluationResult:
+ url: str
+ result: dict
+ name: str | None = None
+ id: str | None = None
+
+ @property
+ def known_frame_urls(self) -> list[str]:
+ return [
+ v.get('attributes', {}).get('src')
+ for v in self.map.values()
+ if v.get('hasIframeContent') and v.get('attributes', {}).get('src')
+ ]
+
+ @property
+ def map(self) -> dict:
+ return self.result.get('map', {})
+
+ @property
+ def map_size(self) -> int:
+ return len(self.map)
+
+ @property
+ def perf_metrics(self) -> dict:
+ return self.result.get('perfMetrics', {})
+
+ @property
+ def short_url(self) -> str:
+ return self.url[:50] + '...' if len(self.url) > 50 else self.url
+
+ @property
+ def root_id(self) -> str | None:
+ return self.result.get('rootId')
+
+
class DomService:
logger: logging.Logger