codecraftai-uia 1.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccai/uia/__init__.py +0 -0
- ccai/uia/cli/__init__.py +0 -0
- ccai/uia/cli/cmdtree/__init__.py +0 -0
- ccai/uia/cli/cmdtree/mapping/__init__.py +12 -0
- ccai/uia/cli/cmdtree/mapping/monitor.py +263 -0
- ccai/uia/cli/uia_command.py +25 -0
- ccai/uia/constraints.py +2 -0
- ccai/uia/exceptions.py +36 -0
- ccai/uia/factory.py +30 -0
- ccai/uia/model/declarative.py +519 -0
- ccai/uia/platforms/__init__.py +0 -0
- ccai/uia/platforms/base.py +1049 -0
- ccai/uia/platforms/linux/__init__.py +2 -0
- ccai/uia/platforms/linux/agents/common/pyatspi_agent.py +148 -0
- ccai/uia/platforms/linux/agents/linuxbaseagents.py +138 -0
- ccai/uia/platforms/linux/agents/wayland/gnome/broker_client.py +89 -0
- ccai/uia/platforms/linux/agents/wayland/gnome/waylandgnomewindowmanageragent.py +421 -0
- ccai/uia/platforms/linux/agents/wayland/other/waylandotherwindowmanageragent.py +14 -0
- ccai/uia/platforms/linux/agents/x11/x11windowmanageragent.py +655 -0
- ccai/uia/platforms/linux/automation.py +157 -0
- ccai/uia/platforms/linux/mappings/__init__.py +0 -0
- ccai/uia/platforms/linux/mappings/calculator.py +43 -0
- ccai/uia/platforms/linux/mappings/libreoffice_calc.py +73 -0
- ccai/uia/platforms/linux/mappings/libreoffice_draw.py +57 -0
- ccai/uia/platforms/linux/platformdetect.py +130 -0
- ccai/uia/platforms/linux/wrappers/__init__.py +4 -0
- ccai/uia/platforms/linux/wrappers/controls.py +352 -0
- ccai/uia/platforms/linux/wrappers/dialogelement.py +115 -0
- ccai/uia/platforms/linux/wrappers/factory.py +91 -0
- ccai/uia/platforms/linux/wrappers/menuelement.py +151 -0
- ccai/uia/platforms/linux/wrappers/tableelement.py +189 -0
- ccai/uia/platforms/linux/wrappers/uiaapplication.py +71 -0
- ccai/uia/platforms/linux/wrappers/uiaelement.py +348 -0
- ccai/uia/platforms/linux/wrappers/uiawindow.py +126 -0
- ccai/uia/platforms/macos/__init__.py +0 -0
- ccai/uia/platforms/macos/applications/__init__.py +0 -0
- ccai/uia/platforms/macos/applications/appautomator.py +10 -0
- ccai/uia/platforms/macos/applications/appcalculator.py +11 -0
- ccai/uia/platforms/macos/applications/appcalendar.py +11 -0
- ccai/uia/platforms/macos/applications/appconsole.py +10 -0
- ccai/uia/platforms/macos/applications/appcontacts.py +10 -0
- ccai/uia/platforms/macos/applications/appdictionary.py +10 -0
- ccai/uia/platforms/macos/applications/appfinder.py +10 -0
- ccai/uia/platforms/macos/applications/appfontbook.py +10 -0
- ccai/uia/platforms/macos/applications/appkeynote.py +11 -0
- ccai/uia/platforms/macos/applications/appmail.py +10 -0
- ccai/uia/platforms/macos/applications/appmaps.py +10 -0
- ccai/uia/platforms/macos/applications/appmessages.py +10 -0
- ccai/uia/platforms/macos/applications/appmusic.py +10 -0
- ccai/uia/platforms/macos/applications/appnotes.py +10 -0
- ccai/uia/platforms/macos/applications/appnumbers.py +10 -0
- ccai/uia/platforms/macos/applications/apppages.py +10 -0
- ccai/uia/platforms/macos/applications/appphotos.py +10 -0
- ccai/uia/platforms/macos/applications/apppreview.py +10 -0
- ccai/uia/platforms/macos/applications/appquicktimeplayer.py +10 -0
- ccai/uia/platforms/macos/applications/appreminders.py +10 -0
- ccai/uia/platforms/macos/applications/appsafari.py +10 -0
- ccai/uia/platforms/macos/applications/appscripteditor.py +10 -0
- ccai/uia/platforms/macos/applications/appshortcuts.py +10 -0
- ccai/uia/platforms/macos/applications/appstocks.py +10 -0
- ccai/uia/platforms/macos/applications/appsystemsettings.py +10 -0
- ccai/uia/platforms/macos/applications/appterminal.py +11 -0
- ccai/uia/platforms/macos/applications/apptextedit.py +10 -0
- ccai/uia/platforms/macos/applications/apptv.py +11 -0
- ccai/uia/platforms/macos/appscript/__init__.py +0 -0
- ccai/uia/platforms/macos/appscript/asdatabaseevents.py +10 -0
- ccai/uia/platforms/macos/appscript/asimageevents.py +10 -0
- ccai/uia/platforms/macos/appscript/assystemevents.py +42 -0
- ccai/uia/platforms/macos/automation.py +90 -0
- ccai/uia/platforms/macos/mappings/__init__.py +5 -0
- ccai/uia/platforms/macos/mappings/calculator.py +47 -0
- ccai/uia/platforms/macos/mappings/excel.py +281 -0
- ccai/uia/platforms/macos/uiacatalog.py +90 -0
- ccai/uia/platforms/macos/wrappers/__init__.py +7 -0
- ccai/uia/platforms/macos/wrappers/controls.py +147 -0
- ccai/uia/platforms/macos/wrappers/sbprocess.py +24 -0
- ccai/uia/platforms/macos/wrappers/sbwindow.py +17 -0
- ccai/uia/platforms/macos/wrappers/uiaaccessibility.py +648 -0
- ccai/uia/platforms/macos/wrappers/uiaapplication.py +456 -0
- ccai/uia/platforms/macos/wrappers/uiaicon.py +13 -0
- ccai/uia/platforms/macos/wrappers/uiametadataitem.py +786 -0
- ccai/uia/platforms/macos/wrappers/uiametadataquery.py +98 -0
- ccai/uia/platforms/macos/wrappers/uiawindow.py +309 -0
- ccai/uia/platforms/macos/wrappers/uiaworkspace.py +189 -0
- ccai/uia/platforms/macos/wrappers/wrappedobject.py +22 -0
- ccai/uia/platforms/windows/__init__.py +0 -0
- ccai/uia/py.typed +0 -0
- ccai/uia/support/linux/wayland-gnome/automation-broker/automation-broker-ext/extension.js +314 -0
- ccai/uia/support/linux/wayland-gnome/automation-broker/automation-broker-ext/metadata.json +10 -0
- ccai/uia/support/linux/wayland-gnome/automation-broker/automation-broker-server/broker_service.py +182 -0
- ccai/uia/wellknown.py +53 -0
- codecraftai_uia-1.5.0.dist-info/METADATA +101 -0
- codecraftai_uia-1.5.0.dist-info/RECORD +96 -0
- codecraftai_uia-1.5.0.dist-info/WHEEL +4 -0
- codecraftai_uia-1.5.0.dist-info/entry_points.txt +3 -0
- codecraftai_uia-1.5.0.dist-info/licenses/LICENSE.md +204 -0
ccai/uia/__init__.py
ADDED
|
File without changes
|
ccai/uia/cli/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
from ccai.arcli.model.groupingcommand import GroupingCommand
|
|
3
|
+
from ccai.uia.cli.cmdtree.mapping.monitor import MonitorCommand
|
|
4
|
+
|
|
5
|
+
class MappingCommand(GroupingCommand):
|
|
6
|
+
|
|
7
|
+
def __init__(self):
|
|
8
|
+
super().__init__("mapping", self.execute)
|
|
9
|
+
self.add_command(MonitorCommand())
|
|
10
|
+
|
|
11
|
+
def execute(self, context):
|
|
12
|
+
pass
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
from ccai.arcli.model.command import Command
|
|
2
|
+
from ccai.arcli.model.fields.argfield import ArgField
|
|
3
|
+
from ccai.arcli.model.fields.optionfield import OptionField
|
|
4
|
+
from ccai.arcli.model.parameters.stringparameter import StringParameter
|
|
5
|
+
from ccai.uia.factory import AutomationFactory
|
|
6
|
+
import subprocess
|
|
7
|
+
import time
|
|
8
|
+
import os
|
|
9
|
+
import json
|
|
10
|
+
import yaml
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# The platform wrapper modules import OS-specific accessibility libraries
|
|
15
|
+
# (pyatspi on Linux, AppKit/ScriptingBridge on macOS) at module top level, so
|
|
16
|
+
# importing both unconditionally made this CLI command fail to load on any host
|
|
17
|
+
# missing the other platform's libraries (e.g. `import AppKit` on Linux). Import
|
|
18
|
+
# each lazily and fall back to an inert stand-in class when its platform library
|
|
19
|
+
# is absent: nothing is ever an instance of the stand-in, so the isinstance
|
|
20
|
+
# branches below are simply skipped on the wrong platform (matching the lazy
|
|
21
|
+
# per-platform imports already used by AutomationFactory).
|
|
22
|
+
try:
|
|
23
|
+
from ccai.uia.platforms.linux.wrappers.uiaelement import LinuxElement
|
|
24
|
+
except ImportError:
|
|
25
|
+
class LinuxElement:
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
from ccai.uia.platforms.macos.wrappers.uiaaccessibility import UiaAccessibilityElement
|
|
30
|
+
except ImportError:
|
|
31
|
+
class UiaAccessibilityElement:
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
class MonitorCommand(Command):
|
|
35
|
+
|
|
36
|
+
def __init__(self):
|
|
37
|
+
super().__init__("monitor", self.execute)
|
|
38
|
+
self.add_argument(ArgField("app_command", ptype=StringParameter, help="The application command to run and monitor"))
|
|
39
|
+
self.add_option(OptionField("--hint", alias="hint", ptype=StringParameter, required=True, help="Processing hint to find the application (e.g. name)"))
|
|
40
|
+
self.add_option(OptionField("--format", alias="format", ptype=StringParameter, default="json", help="Output format: json or yaml"))
|
|
41
|
+
self.add_option(OptionField("--output", alias="output", ptype=StringParameter, required=False, help="Optional file path to write results to"))
|
|
42
|
+
|
|
43
|
+
def execute(self, context, app_command, hint, format, output):
|
|
44
|
+
automation = AutomationFactory.get_automation_engine()
|
|
45
|
+
app = None
|
|
46
|
+
we_launched_it = False
|
|
47
|
+
|
|
48
|
+
# 1. Try to find existing application
|
|
49
|
+
print(f"Searching for application with hint: '{hint}'...", file=sys.stderr)
|
|
50
|
+
app = automation.get_application_by_name(hint)
|
|
51
|
+
|
|
52
|
+
if not app:
|
|
53
|
+
# 2. Launch if not found
|
|
54
|
+
print(f"Application not found. Launching: {app_command}", file=sys.stderr)
|
|
55
|
+
proc = subprocess.Popen(app_command, shell=True)
|
|
56
|
+
we_launched_it = True
|
|
57
|
+
|
|
58
|
+
# Wait for it to appear
|
|
59
|
+
for i in range(20):
|
|
60
|
+
time.sleep(1)
|
|
61
|
+
app = automation.get_application_by_name(hint)
|
|
62
|
+
if app:
|
|
63
|
+
break
|
|
64
|
+
else:
|
|
65
|
+
print("Found running application.", file=sys.stderr)
|
|
66
|
+
|
|
67
|
+
if not app:
|
|
68
|
+
print("Error: Could not find application even after launch.", file=sys.stderr)
|
|
69
|
+
if we_launched_it:
|
|
70
|
+
proc.kill()
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
print(f"Attached to app: {app.name}", file=sys.stderr)
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
# 3. Walk Tree
|
|
77
|
+
# We need the main window usually
|
|
78
|
+
# But let's dump from the App root if possible, or iterate windows
|
|
79
|
+
print("Walking UI tree...", file=sys.stderr)
|
|
80
|
+
|
|
81
|
+
tree_data = {
|
|
82
|
+
"application": app.name,
|
|
83
|
+
"windows": [],
|
|
84
|
+
"menu_bar": None
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
# Wait for windows
|
|
88
|
+
windows = []
|
|
89
|
+
for i in range(5):
|
|
90
|
+
windows = app.get_windows()
|
|
91
|
+
if windows: break
|
|
92
|
+
time.sleep(1)
|
|
93
|
+
|
|
94
|
+
for window in windows:
|
|
95
|
+
win_data = self._walk_element(window)
|
|
96
|
+
tree_data["windows"].append(win_data)
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
menu_bar = app.find_first_by_role("AXMenuBar")
|
|
100
|
+
except Exception:
|
|
101
|
+
menu_bar = None
|
|
102
|
+
|
|
103
|
+
if menu_bar is not None:
|
|
104
|
+
tree_data["menu_bar"] = self._walk_element(menu_bar)
|
|
105
|
+
|
|
106
|
+
# 4. Dump Output
|
|
107
|
+
if format.lower() == "yaml":
|
|
108
|
+
output_text = yaml.dump(tree_data, sort_keys=False)
|
|
109
|
+
else:
|
|
110
|
+
output_text = json.dumps(tree_data, indent=2)
|
|
111
|
+
|
|
112
|
+
if output:
|
|
113
|
+
output_dir = os.path.dirname(output)
|
|
114
|
+
if output_dir:
|
|
115
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
116
|
+
with open(output, "w", encoding="utf-8") as outfile:
|
|
117
|
+
outfile.write(output_text)
|
|
118
|
+
print(f"Wrote mapping output to: {output}", file=sys.stderr)
|
|
119
|
+
else:
|
|
120
|
+
print(output_text)
|
|
121
|
+
|
|
122
|
+
finally:
|
|
123
|
+
# 5. Cleanup
|
|
124
|
+
if we_launched_it:
|
|
125
|
+
print("Closing application...", file=sys.stderr)
|
|
126
|
+
# Try graceful close first?
|
|
127
|
+
# For now, just terminate the process we started if possible
|
|
128
|
+
# Because we used shell=True, proc.terminate() kills the sh, not the app usually
|
|
129
|
+
# But let's try.
|
|
130
|
+
try:
|
|
131
|
+
proc.terminate()
|
|
132
|
+
# Also try to close the app via UI automation if possible
|
|
133
|
+
# app.close() # Not standard API yet?
|
|
134
|
+
except Exception:
|
|
135
|
+
# Best-effort cleanup; a failed terminate must not mask the mapping result or error.
|
|
136
|
+
pass
|
|
137
|
+
else:
|
|
138
|
+
print("Detaching from application (leaving it running).", file=sys.stderr)
|
|
139
|
+
|
|
140
|
+
def _walk_element(self, element, depth=0):
|
|
141
|
+
# Unwrap if we were handed a platform wrapper with a native object
|
|
142
|
+
native_obj = getattr(element, "native_obj", None)
|
|
143
|
+
if native_obj is not None:
|
|
144
|
+
if isinstance(native_obj, UiaAccessibilityElement):
|
|
145
|
+
element = native_obj
|
|
146
|
+
|
|
147
|
+
title = ""
|
|
148
|
+
value = None
|
|
149
|
+
role = ""
|
|
150
|
+
description = ""
|
|
151
|
+
bounds = (0, 0, 0, 0)
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
title = getattr(element, "title", "") or ""
|
|
155
|
+
except Exception:
|
|
156
|
+
title = ""
|
|
157
|
+
|
|
158
|
+
try:
|
|
159
|
+
role = getattr(element, "role_name", getattr(element, "role", "")) or ""
|
|
160
|
+
except Exception:
|
|
161
|
+
role = ""
|
|
162
|
+
|
|
163
|
+
try:
|
|
164
|
+
description = getattr(element, "description", "") or ""
|
|
165
|
+
except Exception:
|
|
166
|
+
description = ""
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
bounds = getattr(element, "bounds", (0, 0, 0, 0)) or (0, 0, 0, 0)
|
|
170
|
+
except Exception:
|
|
171
|
+
bounds = (0, 0, 0, 0)
|
|
172
|
+
|
|
173
|
+
try:
|
|
174
|
+
if isinstance(element, UiaAccessibilityElement):
|
|
175
|
+
value = element._get_value_text()
|
|
176
|
+
except Exception:
|
|
177
|
+
value = None
|
|
178
|
+
|
|
179
|
+
if value is None:
|
|
180
|
+
try:
|
|
181
|
+
value = getattr(element, "text", None)
|
|
182
|
+
except Exception:
|
|
183
|
+
value = None
|
|
184
|
+
|
|
185
|
+
if value is None:
|
|
186
|
+
try:
|
|
187
|
+
value = getattr(element, "value", None)
|
|
188
|
+
except Exception:
|
|
189
|
+
value = None
|
|
190
|
+
|
|
191
|
+
# Basic attributes
|
|
192
|
+
identifier = ""
|
|
193
|
+
help_text = ""
|
|
194
|
+
try:
|
|
195
|
+
identifier = getattr(element, "identifier", "") or ""
|
|
196
|
+
except Exception:
|
|
197
|
+
identifier = ""
|
|
198
|
+
|
|
199
|
+
try:
|
|
200
|
+
help_text = getattr(element, "help", "") or ""
|
|
201
|
+
except Exception:
|
|
202
|
+
help_text = ""
|
|
203
|
+
|
|
204
|
+
data = {
|
|
205
|
+
"name": getattr(element, "name", "") if hasattr(element, "name") else title,
|
|
206
|
+
"title": title,
|
|
207
|
+
"identifier": identifier,
|
|
208
|
+
"help": help_text,
|
|
209
|
+
"value": value,
|
|
210
|
+
"role": role,
|
|
211
|
+
"description": description,
|
|
212
|
+
"states": [],
|
|
213
|
+
"bounds": list(bounds) if isinstance(bounds, tuple) else bounds,
|
|
214
|
+
"interfaces": [],
|
|
215
|
+
"children": []
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
# Get states
|
|
219
|
+
try:
|
|
220
|
+
if isinstance(element, LinuxElement):
|
|
221
|
+
states_enum = element.access_agent.get_states(element.native_obj)
|
|
222
|
+
data["states"] = [str(s).split('.')[-1] for s in states_enum]
|
|
223
|
+
except Exception:
|
|
224
|
+
# Best-effort mapping; an element whose states cannot be read keeps an empty state list.
|
|
225
|
+
pass
|
|
226
|
+
|
|
227
|
+
# Get interfaces/attributes
|
|
228
|
+
try:
|
|
229
|
+
if isinstance(element, LinuxElement):
|
|
230
|
+
native = getattr(element, '_native_obj', element) if hasattr(element, '_native_obj') else element.native_obj
|
|
231
|
+
# PyAtspi specific: list interfaces
|
|
232
|
+
if 'pyatspi' in sys.modules:
|
|
233
|
+
pyatspi_module = sys.modules['pyatspi']
|
|
234
|
+
start_interfaces = pyatspi_module.listInterfaces(native)
|
|
235
|
+
else:
|
|
236
|
+
start_interfaces = []
|
|
237
|
+
data["interfaces"] = [str(iface_name) for iface_name in start_interfaces]
|
|
238
|
+
except Exception:
|
|
239
|
+
# Best-effort mapping; interface discovery is optional diagnostic information.
|
|
240
|
+
pass
|
|
241
|
+
|
|
242
|
+
# Helper to recurse
|
|
243
|
+
try:
|
|
244
|
+
if isinstance(element, LinuxElement):
|
|
245
|
+
native = getattr(element, '_native_obj', element) if hasattr(element, '_native_obj') else element.native_obj
|
|
246
|
+
children = element.access_agent.get_children(native)
|
|
247
|
+
for child in children:
|
|
248
|
+
child_el = LinuxElement(child, element.access_agent, element.wm_agent)
|
|
249
|
+
data["children"].append(self._walk_element(child_el, depth + 1))
|
|
250
|
+
elif isinstance(element, UiaAccessibilityElement):
|
|
251
|
+
children = element.children()
|
|
252
|
+
for child in children:
|
|
253
|
+
data["children"].append(self._walk_element(child, depth + 1))
|
|
254
|
+
else:
|
|
255
|
+
if hasattr(element, "children"):
|
|
256
|
+
children = element.children()
|
|
257
|
+
for child in children:
|
|
258
|
+
data["children"].append(self._walk_element(child, depth + 1))
|
|
259
|
+
except Exception:
|
|
260
|
+
# Best-effort mapping; an element that goes defunct keeps the children found so far.
|
|
261
|
+
pass
|
|
262
|
+
|
|
263
|
+
return data
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
import sys
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
# Add sources to path if running directly
|
|
6
|
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../../")))
|
|
7
|
+
|
|
8
|
+
from ccai.arcli.model.entrycommand import EntryCommand
|
|
9
|
+
from ccai.uia.cli.cmdtree.mapping import MappingCommand
|
|
10
|
+
|
|
11
|
+
class UiaCommand(EntryCommand):
|
|
12
|
+
|
|
13
|
+
def __init__(self):
|
|
14
|
+
super().__init__("uia", self.execute)
|
|
15
|
+
self.add_command(MappingCommand())
|
|
16
|
+
|
|
17
|
+
def execute(self, context):
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
def main():
|
|
21
|
+
cmd = UiaCommand()
|
|
22
|
+
cmd(args=sys.argv[1:])
|
|
23
|
+
|
|
24
|
+
if __name__ == "__main__":
|
|
25
|
+
main()
|
ccai/uia/constraints.py
ADDED
ccai/uia/exceptions.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
class UIAException(Exception):
|
|
3
|
+
"""
|
|
4
|
+
Base exception for all UI Automation errors.
|
|
5
|
+
"""
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
class ElementNotFoundError(UIAException):
|
|
9
|
+
"""
|
|
10
|
+
Raised when a UI element cannot be found.
|
|
11
|
+
"""
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
class InteractionError(UIAException):
|
|
15
|
+
"""
|
|
16
|
+
Raised when an interaction with a UI element fails (e.g., click, type).
|
|
17
|
+
"""
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
class PlatformNotSupportedError(UIAException):
|
|
21
|
+
"""
|
|
22
|
+
Raised when a requested feature or action is not supported on the current platform.
|
|
23
|
+
"""
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
class ConfigurationError(UIAException):
|
|
27
|
+
"""
|
|
28
|
+
Raised when a configuration error occurs.
|
|
29
|
+
"""
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
class SemanticError(UIAException):
|
|
33
|
+
"""
|
|
34
|
+
Raised when a semantic error occurs.
|
|
35
|
+
"""
|
|
36
|
+
pass
|
ccai/uia/factory.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
import platform
|
|
3
|
+
|
|
4
|
+
from ccai.uia.platforms.base import AutomationEngine
|
|
5
|
+
|
|
6
|
+
class AutomationFactory:
|
|
7
|
+
"""
|
|
8
|
+
Factory class for creating automation engines based on the current platform.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
@staticmethod
|
|
12
|
+
def get_automation_engine() -> AutomationEngine:
|
|
13
|
+
"""
|
|
14
|
+
Returns the automation engine for the current platform.
|
|
15
|
+
|
|
16
|
+
:returns: An instance of the platform-specific automation engine.
|
|
17
|
+
"""
|
|
18
|
+
system = platform.system()
|
|
19
|
+
|
|
20
|
+
if system == "Darwin":
|
|
21
|
+
from ccai.uia.platforms.macos.automation import MacOSAutomation
|
|
22
|
+
return MacOSAutomation()
|
|
23
|
+
elif system == "Windows":
|
|
24
|
+
# Placeholder for Windows support
|
|
25
|
+
raise NotImplementedError("Windows automation is not yet implemented.")
|
|
26
|
+
elif system == "Linux":
|
|
27
|
+
from ccai.uia.platforms.linux.automation import LinuxAutomation
|
|
28
|
+
return LinuxAutomation()
|
|
29
|
+
else:
|
|
30
|
+
raise NotImplementedError(f"Unsupported platform: {system}")
|