Skip to content

Commit 4fbfc6b

Browse files
authored
added tests and fixed workflow issues in execution (#119)
* added tests and fixed workflow issues in execution * fixed linting issues * fixed liniting in test * fixed all cubic comments
1 parent bb55b2d commit 4fbfc6b

17 files changed

+1751
-31
lines changed

workflows/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ python cli.py run-workflow-no-ai my_workflow.json
4545
- **10-100x Faster**: 5-10s vs 20-40s for LLM-based
4646
- **90% Cheaper**: Minimal LLM usage
4747

48-
### 🎯 Variables in Workflows
48+
### 🎯 Semantic-Only Multi-Strategy Element Finding
49+
- **No CSS/XPath**: 100% semantic strategies (text, role, ARIA, placeholder, etc.)
50+
- **7 Fallback Strategies**: text_exact → role_text → aria_label → placeholder → title → alt_text → text_fuzzy
51+
- **Works WITH Browser-Use**: Finds element index in DOM state, then uses browser-use's controller
52+
- **Fast & Robust**: Direct index lookup when strategies match, falls back to AI when needed
53+
- **Human-Readable**: Workflow YAML contains semantic strategies, not brittle selectors
54+
55+
### 🔄 Variables in Workflows
4956
- **Reusable Workflows**: Parameterize dynamic values
5057
- **Semantic Targeting**: Use `{variable}` in `target_text`
5158
- **Auto-Extraction**: LLM suggests variables automatically

workflows/tests/run_all_tests.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
"""
2+
Run all unit tests for the semantic-only workflow system.
3+
4+
This script runs all test modules and provides a summary.
5+
"""
6+
7+
import subprocess
8+
import sys
9+
10+
11+
def run_test_file(test_file):
12+
"""Run a single test file and return (passed, failed)"""
13+
print(f'\n{"=" * 80}')
14+
print(f'Running {test_file}')
15+
print(f'{"=" * 80}')
16+
17+
result = subprocess.run(['uv', 'run', 'python', f'workflows/tests/{test_file}'], capture_output=True, text=True)
18+
19+
# Print output
20+
print(result.stdout)
21+
if result.stderr:
22+
print(result.stderr)
23+
24+
# Parse results from output
25+
for line in result.stdout.split('\n'):
26+
if 'Test Results:' in line:
27+
# Extract passed and failed counts
28+
# Format: "Test Results: X passed, Y failed"
29+
parts = line.split(':')[1].strip().split(',')
30+
passed = int(parts[0].split()[0])
31+
failed = int(parts[1].split()[0])
32+
return (passed, failed)
33+
34+
# If we couldn't parse, check exit code
35+
if result.returncode == 0:
36+
return (1, 0) # Assume some tests passed
37+
else:
38+
return (0, 1) # Assume some tests failed
39+
40+
41+
def main():
42+
"""Run all tests and provide summary"""
43+
test_files = [
44+
'test_selector_generator.py',
45+
'test_element_finder.py',
46+
'test_workflow_execution.py',
47+
]
48+
49+
print('\n' + '=' * 80)
50+
print('SEMANTIC-ONLY WORKFLOW SYSTEM - UNIT TEST SUITE')
51+
print('=' * 80)
52+
53+
total_passed = 0
54+
total_failed = 0
55+
56+
results = []
57+
58+
for test_file in test_files:
59+
passed, failed = run_test_file(test_file)
60+
total_passed += passed
61+
total_failed += failed
62+
results.append((test_file, passed, failed))
63+
64+
# Print summary
65+
print('\n' + '=' * 80)
66+
print('TEST SUITE SUMMARY')
67+
print('=' * 80)
68+
69+
for test_file, passed, failed in results:
70+
status = '✅ PASS' if failed == 0 else '❌ FAIL'
71+
print(f'{status} {test_file:40s} {passed:3d} passed, {failed:3d} failed')
72+
73+
print(f'\n{"=" * 80}')
74+
print(f'TOTAL: {total_passed} passed, {total_failed} failed')
75+
print(f'{"=" * 80}\n')
76+
77+
if total_failed > 0:
78+
print('❌ Some tests failed!')
79+
sys.exit(1)
80+
else:
81+
print('✅ All tests passed!')
82+
sys.exit(0)
83+
84+
85+
if __name__ == '__main__':
86+
main()

0 commit comments

Comments
 (0)