Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
5.9 KiB
5.9 KiB
UDM Pro Automation Improvements
Last Updated: 2026-01-14
Status: ✅ Enhanced with Context-Aware Detection
Summary
The automation script has been improved with:
- ✅ Enhanced context-aware detection - Smart methods before brute force
- ✅ Optional aggressive auto-click - Only enabled when explicitly requested
- ✅ Comprehensive documentation - Clear warnings and usage guidelines
Detection Strategy Order
The script now follows this priority order:
1. Standard Selectors (50+ methods)
- Text-based selectors
- Aria-label selectors
- Data attributes
- Class-based patterns
- Icon-based detection
- XPath selectors
2. Context-Aware Detection (NEW - Default)
- Near "Static Routes" text: Finds buttons in parent/sibling elements
- Table headers: Specifically looks for buttons in table headers
- Prioritization: Plus icons, table headers, icon-only buttons get priority
- Smart filtering: Skips known non-Add buttons
3. JavaScript Evaluation
- Evaluates page structure
- Finds buttons with specific characteristics
- Tries multiple click methods
4. Aggressive Auto-Click (OPTIONAL - Last Resort)
- Default: Disabled
- Enable:
AGGRESSIVE_AUTO_CLICK=true - Systematically clicks through buttons
- Only used when explicitly enabled
5. Manual Intervention (Fallback)
- Waits for user to click Add button
- Automatically detects when form appears
- Continues automatically
Usage
Default Mode (Recommended)
cd /home/intlc/projects/proxmox
UNIFI_USERNAME=unifi_api UNIFI_PASSWORD='L@kers2010$$' \
HEADLESS=false \
node scripts/unifi/configure-static-route-playwright.js
What happens:
- Tries 50+ standard selectors
- Tries context-aware detection (near "Static Routes", table headers)
- Tries JavaScript evaluation
- If all fail: Waits for manual Add button click (120 seconds)
- Automatically continues after form appears
Aggressive Mode (Last Resort)
cd /home/intlc/projects/proxmox
UNIFI_USERNAME=unifi_api UNIFI_PASSWORD='L@kers2010$$' \
AGGRESSIVE_AUTO_CLICK=true \
HEADLESS=false \
node scripts/unifi/configure-static-route-playwright.js
What happens:
- Tries all standard methods
- Tries context-aware detection
- Tries JavaScript evaluation
- If enabled: Tries aggressive auto-click (clicks through all buttons)
- If still fails: Waits for manual intervention
Environment Variables
| Variable | Default | Description |
|---|---|---|
AGGRESSIVE_AUTO_CLICK |
false |
Enable aggressive auto-click as last resort |
HEADLESS |
true |
Run browser in headless mode |
PAUSE_MODE |
false |
Pause at key points for manual inspection |
DRY_RUN |
false |
Test mode without making changes |
Risks and Warnings
Aggressive Auto-Click Risks
⚠️ Only enable if absolutely necessary
Risks:
- May click unintended buttons (navigation, settings, etc.)
- Could trigger side effects (opening menus, dialogs, navigating away)
- May be slow (up to 90 seconds testing 30 buttons)
- Could break if UI structure changes
- Browser window may flicker/jump visibly
When to use:
- Standard methods have failed
- Context-aware detection has failed
- You're willing to accept potential side effects
- You're monitoring the browser window
When NOT to use:
- In production without testing
- When UI structure is unknown
- When you need predictable behavior
- When you can't monitor the browser
Best Practices
1. Use Default Mode First
- Most reliable and predictable
- Uses smart context-aware detection
- Falls back to manual intervention if needed
2. Identify Selectors Manually
- Use browser DevTools to inspect Add button
- Find stable selector (data attribute, stable class)
- Add to standard selector list
- Most maintainable long-term solution
3. Monitor First Run
- Run with
HEADLESS=falsefirst time - Watch what the script does
- Verify it finds the correct button
- Check for any side effects
4. Use Aggressive Mode Sparingly
- Only when other methods fail
- Monitor browser window
- Be prepared to stop if issues occur
- Document any side effects
Troubleshooting
Context-Aware Detection Not Finding Button
-
Check page structure:
- Verify "Static Routes" text is visible
- Check if table headers exist
- Inspect button location in DevTools
-
Improve selectors:
- Manually identify button selector
- Add to standard selector list
- Update context-aware detection logic
-
Enable aggressive mode:
- Use as last resort
- Monitor carefully
- Document results
Aggressive Auto-Click Causing Issues
-
Stop the script immediately
-
Check what was clicked:
- Review screenshots
- Check browser state
- Verify no unintended changes
-
Use manual intervention instead:
- Run with
HEADLESS=false - Click Add button manually
- Script will continue automatically
- Run with
Performance Comparison
| Method | Speed | Reliability | Side Effects | Recommended |
|---|---|---|---|---|
| Standard Selectors | ⚡ Fast | ⭐⭐⭐ High | ✅ None | ✅ Yes |
| Context-Aware | ⚡ Fast | ⭐⭐⭐ High | ✅ None | ✅ Yes |
| JavaScript Eval | ⚡ Fast | ⭐⭐ Medium | ✅ None | ✅ Yes |
| Aggressive Auto-Click | 🐌 Slow | ⭐ Low | ⚠️ Possible | ⚠️ Last Resort |
| Manual Intervention | ⚡ Fast | ⭐⭐⭐ High | ✅ None | ✅ Yes |
Future Improvements
-
Manual Selector Identification
- Use DevTools to find stable selector
- Add to standard selector list
- Remove need for aggressive auto-click
-
Direct URL Navigation
- If UniFi exposes direct URL for Add Route form
- Navigate directly, skip button detection
-
API-Based Approach
- If UniFi adds API support for static routes
- Use API instead of browser automation
Last Updated: 2026-01-14
Status: ✅ Improvements Complete