MCPcopy Create free account
hub / github.com/browser-use/macOS-use / MacElementNode

Class MacElementNode

mlx_use/mac/element.py:7–197  ·  view source on GitHub ↗

Represents a UI element in macOS with enhanced accessibility information

Source from the content-addressed store, hash-verified

5
6@dataclass
7class MacElementNode:
8 """Represents a UI element in macOS with enhanced accessibility information"""
9 # Required fields
10 role: str
11 identifier: str
12 attributes: Dict[str, Any]
13 is_visible: bool
14 app_pid: int
15
16 # Optional fields
17 children: List['MacElementNode'] = field(default_factory=list)
18 parent: Optional['MacElementNode'] = None
19 is_interactive: bool = False
20 highlight_index: Optional[int] = None
21 _element = None # Store AX element reference
22
23 @property
24 def actions(self) -> List[str]:
25 """Get the list of available actions for this element"""
26 return self.attributes.get('actions', [])
27
28 @property
29 def enabled(self) -> bool:
30 """Check if the element is enabled"""
31 return self.attributes.get('enabled', True)
32
33 @property
34 def position(self) -> Optional[tuple]:
35 """Get the element's position"""
36 return self.attributes.get('position')
37
38 @property
39 def size(self) -> Optional[tuple]:
40 """Get the element's size"""
41 return self.attributes.get('size')
42
43 def __repr__(self) -> str:
44 """Enhanced string representation including more attributes"""
45 role_str = f'<{self.role}'
46
47 # Add important attributes to the string representation
48 important_attrs = ['title', 'value', 'description', 'enabled']
49 for key in important_attrs:
50 if key in self.attributes:
51 role_str += f' {key}="{self.attributes[key]}"'
52
53 # Add position and size if available
54 if self.position:
55 role_str += f' pos={self.position}'
56 if self.size:
57 role_str += f' size={self.size}'
58
59 role_str += '>'
60
61 # Add status indicators
62 extras = []
63 if self.is_interactive:
64 extras.append('interactive')

Callers 2

_process_elementMethod · 0.85
build_treeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected