Visual Feedback and Highlighting
Overviewโ
Brobot provides visual feedback capabilities to help with debugging and monitoring automation execution. The system includes basic highlighting of matches and console action reporting. Visual feedback helps developers understand what the automation is doing and quickly identify issues.
Note: This guide documents the currently implemented highlighting features. Some advanced features (labels, animations, custom colors per StateImage) are planned for future releases.
Prerequisitesโ
Before using visual feedback features, ensure you understand:
- States and StateImage - How to define UI elements
- Actions - How to perform operations on elements
- Testing - How to test automation scripts
Current Implementation Statusโ
โ Working Featuresโ
- Basic highlighting via
MatchHighlighterclass - Console action reporting with
brobot.console.actions.*properties - Aspect-based visual feedback via
VisualFeedbackAspect(limited functionality) - Manual highlighting using
action.highlight()orHighlightOptions
โ ๏ธ Planned Features (Not Yet Implemented)โ
- Custom highlight colors per
StateImage(field exists but not used) - Automatic highlighting of all finds
- Confidence score labels
- Flash animations
- Multiple match color gradients
- Advanced performance tuning
Configurationโ
Working Propertiesโ
Brobot currently supports two highlighting property namespaces:
1. Aspect-Based Visual Feedback (Recommended)โ
Configure via brobot.aspects.visual-feedback.* properties:
# Enable/disable the VisualFeedbackAspect
brobot.aspects.visual-feedback.enabled=true
# Duration in seconds
brobot.aspects.visual-feedback.highlight-duration=2
# Highlight color (YELLOW, RED, GREEN, etc.)
brobot.aspects.visual-feedback.highlight-color=YELLOW
# Show action flow arrows
brobot.aspects.visual-feedback.show-action-flow=true
# Show confidence scores
brobot.aspects.visual-feedback.show-confidence-scores=true
2. Console Action Reporting (Fully Functional)โ
Configure detailed console output:
# Enable console action reporting
brobot.console.actions.enabled=true
# Verbosity: QUIET, NORMAL, VERBOSE
brobot.console.actions.level=VERBOSE
# Show match details (location, score)
brobot.console.actions.show-match-details=true
# Show timing information
brobot.console.actions.show-timing=true
# Use colored output (requires ANSI support)
brobot.console.actions.use-colors=true
# Use unicode icons
brobot.console.actions.use-icons=true
# Report specific action types
brobot.console.actions.report.find=true
brobot.console.actions.report.click=true
brobot.console.actions.report.type=true
brobot.console.actions.report.highlight=false
3. Planned Properties (Defined but Not Implemented)โ
These properties exist in brobot-visual-feedback.properties but have no Java configuration classes to bind them:
# These are PLANNED but not yet functional:
# brobot.highlight.enabled=true
# brobot.highlight.auto-highlight-finds=true
# brobot.highlight.find.color=#00FF00
# brobot.highlight.find.duration=2.0
# ... and 30+ other properties
Important: The
brobot.highlight.*properties are defined in properties files but do not currently work because theVisualFeedbackConfigclass that would bind them has been removed from the codebase.
Properties Filesโ
The default properties are in:
brobot/library/src/main/resources/brobot-visual-feedback.properties
For complete property documentation, see Properties Reference.
Usageโ
Method 1: Manual Highlighting with Action APIโ
The most reliable way to highlight elements:
import io.github.jspinak.brobot.action.Action;
import io.github.jspinak.brobot.action.ActionResult;
import io.github.jspinak.brobot.action.basic.highlight.HighlightOptions;
import io.github.jspinak.brobot.action.ObjectCollection;
import io.github.jspinak.brobot.model.state.StateImage;
import org.springframework.beans.factory.annotation.Autowired;
public class HighlightExample {
@Autowired
private Action action;
public void highlightButton() {
// Create StateImage
StateImage button = new StateImage.Builder()
.addPattern("button.png")
.setName("SubmitButton")
.build();
// Find the button
ActionResult result = action.find(button);
// Highlight it manually
if (result.isSuccess()) {
HighlightOptions options = new HighlightOptions.Builder()
.setHighlightSeconds(2.0)
.setHighlightColor("yellow")
.build();
ObjectCollection collection = new ObjectCollection.Builder()
.withImages(button)
.build();
action.perform(options, collection);
}
}
}
Method 2: Using MatchHighlighter Directlyโ
For low-level highlighting control:
import io.github.jspinak.brobot.tools.history.draw.MatchHighlighter;
import io.github.jspinak.brobot.action.basic.highlight.HighlightOptions;
import io.github.jspinak.brobot.model.match.Match;
import io.github.jspinak.brobot.model.state.StateObjectMetadata;
import org.springframework.beans.factory.annotation.Autowired;
public class DirectHighlightExample {
@Autowired
private MatchHighlighter matchHighlighter;
public void highlightMatch(Match match) {
HighlightOptions options = new HighlightOptions.Builder()
.setHighlightSeconds(2.0)
.setHighlightColor("red")
.build();
StateObjectMetadata metadata = match.getStateObjectData();
matchHighlighter.highlight(match, metadata, options);
}
}
Method 3: Aspect-Based Visual Feedback (Limited)โ
Enable automatic visual feedback via aspects:
# In application.properties
brobot.aspects.visual-feedback.enabled=true
brobot.aspects.visual-feedback.highlight-duration=2
brobot.aspects.visual-feedback.highlight-color=YELLOW
Note: The
VisualFeedbackAspecthas limited functionality. Much of its highlighting code is commented out awaiting the restoration of removed classes.
Testing Highlightingโ
Example test using Brobot's test framework:
import io.github.jspinak.brobot.action.Action;
import io.github.jspinak.brobot.action.ActionResult;
import io.github.jspinak.brobot.action.basic.highlight.HighlightOptions;
import io.github.jspinak.brobot.action.ObjectCollection;
import io.github.jspinak.brobot.model.state.StateImage;
import io.github.jspinak.brobot.test.BrobotTestBase;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.jupiter.api.Assertions.*;
/**
* Test highlighting functionality.
* For more on testing, see the Testing Guide.
*/
@SpringBootTest
public class HighlightingTest extends BrobotTestBase {
@Autowired
private Action action;
@Test
public void testManualHighlighting() {
// Create test image
StateImage testImage = new StateImage.Builder()
.addPattern("test-button.png")
.setName("TestButton")
.build();
// Find and highlight
ActionResult findResult = action.find(testImage);
assertTrue(findResult.isSuccess(), "Should find the test image");
// Manual highlight
HighlightOptions options = new HighlightOptions.Builder()
.setHighlightSeconds(1.0)
.setHighlightColor("green")
.build();
ObjectCollection collection = new ObjectCollection.Builder()
.withImages(testImage)
.build();
ActionResult highlightResult = action.perform(options, collection);
assertTrue(highlightResult.isSuccess(), "Should highlight successfully");
}
}
For more testing patterns, see:
How It Worksโ
Component Architectureโ
-
MatchHighlighter (
io.github.jspinak.brobot.tools.history.draw.MatchHighlighter)- Low-level highlighting implementation
- Wraps SikuliX highlighting functionality
- Supports mock mode (logs instead of displaying)
- Handles timed highlights with custom colors
-
VisualFeedbackAspect (
io.github.jspinak.brobot.aspects.display.VisualFeedbackAspect)- AOP-based automatic visual feedback
- Intercepts find/click/type operations
- Currently has limited functionality (much code commented out)
- For more on aspects, see AspectJ Usage Guide
-
HighlightOptions (
io.github.jspinak.brobot.action.basic.highlight.HighlightOptions)- Configuration for highlight operations
- Specifies duration, color, and behavior
- Used with
action.perform(options, collection)
-
ConsoleActionReporter (part of logging system)
- Reports actions to console with formatting
- Supports colors, icons, and detailed information
- Configured via
brobot.console.actions.*properties
Mock Mode Supportโ
Highlighting works in both live and mock modes:
// In mock mode (headless/CI):
// - Highlighting is logged instead of displayed
// - No AWT/graphics exceptions
// - Fast execution for tests
// In live mode (with display):
// - Visual highlights appear on screen
// - Useful for debugging and demonstrations
For mock mode details, see Mock Mode Guide.
Environment-Specific Configurationโ
Development Profileโ
Maximum visibility for debugging:
# application-development.properties
brobot.console.actions.level=VERBOSE
brobot.console.actions.show-match-details=true
brobot.aspects.visual-feedback.enabled=true
CI/CD Profileโ
Minimal output for automated testing:
# application-ci.properties
brobot.console.actions.level=QUIET
brobot.aspects.visual-feedback.enabled=false
brobot.core.mock=true
Production Profileโ
Essential logging only:
# application-production.properties
brobot.console.actions.enabled=false
brobot.aspects.visual-feedback.enabled=false
Troubleshootingโ
Highlighting Not Appearingโ
Issue: No visual highlights appear on screen
Solutions:
- Verify not in mock mode:
brobot.core.mock=false - Verify aspect is enabled:
brobot.aspects.visual-feedback.enabled=true - Check you're using working features (manual highlighting, not auto-highlighting)
- Verify display is available (not headless environment)
Properties Not Workingโ
Issue: Setting brobot.highlight.* properties has no effect
Solution: These properties are defined but not yet implemented. Use brobot.aspects.visual-feedback.* or brobot.console.actions.* instead.
Mock Mode Issuesโ
Issue: Tests fail with AWT/graphics exceptions
Solution: Extend BrobotTestBase which automatically enables mock mode. See Testing Guide.
Console Outputโ
Enable detailed logging for debugging:
# For highlighting debugging
logging.level.io.github.jspinak.brobot.tools.history.draw.MatchHighlighter=DEBUG
logging.level.io.github.jspinak.brobot.aspects.display.VisualFeedbackAspect=DEBUG
# For action reporting
brobot.console.actions.enabled=true
brobot.console.actions.level=VERBOSE
Limitations and Future Plansโ
Current Limitationsโ
- No auto-highlighting - Must manually call
action.highlight()or useHighlightOptions - No custom colors per StateImage -
StateImage.setHighlightColor()exists but isn't used - No confidence labels - Score display not implemented
- No animations - Flash effects and gradients not available
- Limited aspect functionality - Much of
VisualFeedbackAspectcode is commented out
Planned Enhancementsโ
Future versions may include:
- Automatic highlighting of all find operations
- Custom highlight colors per StateImage (field already exists)
- Confidence score labels on highlights
- Flash animations and gradient colors
- Screenshot capture of highlighted regions
- Video recording with highlights
- Performance optimization for multiple highlights
Contributingโ
If you need advanced highlighting features:
- Check the existing field:
StateImage.highlightColor(line 171 in StateImage.java) - Implement logic to retrieve and use this color in find operations
- Consider creating a
VisualFeedbackConfigclass to bindbrobot.highlight.*properties - Submit a pull request with your improvements
Related Documentationโ
Core Conceptsโ
- States - Define UI elements to highlight
- Actions - Perform operations with highlighting
- Action Convenience Methods - Includes
action.highlight()
Configurationโ
- Properties Reference - All configuration options
- BrobotProperties Usage - Access properties in code
Testing and Debuggingโ
- Testing Introduction - Test framework overview
- Mock Mode Guide - Headless testing
- Image Find Debugging - Comprehensive debugging system
Advanced Topicsโ
- AspectJ Usage Guide - How aspects work
- Search Regions - Define where to look
Best Practicesโ
-
Use Manual Highlighting During Development
// Find, then explicitly highlight for debugging
ActionResult result = action.find(stateImage);
if (result.isSuccess()) {
action.highlight(stateImage); // Convenience method
} -
Enable Console Reporting for Visibility
brobot.console.actions.level=VERBOSE
brobot.console.actions.show-match-details=true -
Use Mock Mode for Tests
@SpringBootTest
public class MyTest extends BrobotTestBase {
// Mock mode automatically enabled
// Highlighting logged instead of displayed
} -
Configure Per Environment
- Development: VERBOSE logging, highlighting enabled
- CI/CD: QUIET logging, mock mode
- Production: Minimal logging, no highlighting
Summaryโ
Brobot's current visual feedback system provides:
- โ
Manual highlighting via
action.highlight()andHighlightOptions - โ
Low-level highlighting via
MatchHighlighter - โ Console action reporting with colors and icons
- โ Mock mode support for headless testing
- โ Aspect-based interception (limited functionality)
Advanced features like automatic highlighting, custom colors per StateImage, and labels are planned for future releases. For now, use manual highlighting and console reporting for effective debugging and monitoring.