Repository navigation
Expand file tree
/
Copy pathtest_window_output.py
More file actions
76 lines (57 loc) · 2.71 KB
/
Copy pathtest_window_output.py
File metadata and controls
76 lines (57 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3
"""
Test get_current_window output to see the actual result format
"""
import sys
import asyncio
from pathlib import Path
import json
# Add automation framework to path
sys.path.insert(0, str(Path(__file__).parent / "automation_framework"))
from rich.console import Console
from rich.panel import Panel
from rich.syntax import Syntax
console = Console()
async def test_window_output():
"""Test get_current_window and show the actual output format"""
console.print("[cyan]🔍 Testing get_current_window output format[/cyan]")
console.print("-" * 50)
try:
from actors.generic.mouse_keyboard import GenericActorStack
actor = GenericActorStack()
console.print("[yellow]📋 Calling get_current_window...[/yellow]")
result = await actor.execute_action("get_current_window")
console.print(f"[green]✅ Raw result type:[/green] {type(result)}")
console.print(f"[green]✅ Raw result value:[/green] {repr(result)}")
if isinstance(result, dict):
console.print("\n[cyan]📊 Dictionary contents:[/cyan]")
for key, value in result.items():
console.print(f" • [bold]{key}:[/bold] {value}")
# Pretty print as JSON
if result:
console.print("\n[cyan]📄 JSON formatted:[/cyan]")
json_str = json.dumps(result, indent=2, ensure_ascii=False)
syntax = Syntax(json_str, "json", theme="monokai", line_numbers=True)
console.print(syntax)
# Test screenshot too
console.print("\n[yellow]📸 Testing screenshot...[/yellow]")
screenshot_result = await actor.execute_action("screenshot", filename="test_output.png")
console.print(f"[green]Screenshot result:[/green] {screenshot_result}")
# Test custom AppleScript
console.print("\n[yellow]🍎 Testing custom AppleScript...[/yellow]")
script = '''
tell application "System Events"
set appList to name of every application process whose visible is true
return "Visible apps: " & (count of appList) & " - " & (item 1 of appList) & ", " & (item 2 of appList)
end tell
'''
script_result = await actor.execute_action("run_applescript", script=script)
console.print(f"[green]AppleScript result:[/green] {script_result}")
console.print(f"[green]AppleScript type:[/green] {type(script_result)}")
await actor.cleanup()
except Exception as e:
console.print(f"[red]❌ Test failed: {e}[/red]")
import traceback
traceback.print_exc()
if __name__ == "__main__":
asyncio.run(test_window_output())