Files
browser-use/browser_use/dom/history_tree_processor/view.py
2024-12-03 09:26:17 +01:00

34 lines
698 B
Python

from dataclasses import dataclass
from typing import Optional
@dataclass
class HashedDomElement:
"""
Hash of the dom element to be used as a unique identifier
"""
branch_path_hash: str
attributes_hash: str
# text_hash: str
@dataclass
class DOMHistoryElement:
tag_name: str
xpath: str
highlight_index: Optional[int]
entire_parent_branch_path: list[str]
attributes: dict[str, str]
shadow_root: bool = False
def to_dict(self) -> dict:
return {
'tag_name': self.tag_name,
'xpath': self.xpath,
'highlight_index': self.highlight_index,
'entire_parent_branch_path': self.entire_parent_branch_path,
'attributes': self.attributes,
'shadow_root': self.shadow_root,
}