Skip to main content
Version: Latest

Quick Migration Reference: ActionOptions to ActionConfig

This guide helps you migrate your existing Brobot automation code from ActionOptions to the new ActionConfig hierarchy.

Quick Reference

Action Type Mapping

ActionType (replaces ActionOptions.Action)New ActionConfig Class
FINDPatternFindOptions, BaseFindOptions
CLICKClickOptions
TYPETypeOptions
DRAGDragOptions
MOVEMouseMoveOptions
MOUSE_DOWNMouseDownOptions
MOUSE_UPMouseUpOptions
DEFINEDefineRegionOptions
HIGHLIGHTHighlightOptions
SCROLL_MOUSE_WHEELScrollMouseWheelOptions
VANISHVanishOptions
CLICK_UNTILClickUntilOptions

Field Mapping

ActionOptions FieldNew Location
minScoresimilarity in find options
clickTypenumberOfClicks + MousePressOptions
textToTypetext in TypeOptions
dragToOffsetX/YRemoved (use target locations)
moveMouseAfterActionAction-specific option

Migration Examples

Find Action

Before (ActionOptions)

// DEPRECATED - ActionOptions class is deprecated
ActionOptions findOptions = new ActionOptions.Builder()
.setAction(ActionType.FIND)
.setSimilarity(0.8)
.setSearchRegions(searchRegions)
.build();

action.perform(findOptions, stateImage);

After (ActionConfig)

PatternFindOptions findOptions = new PatternFindOptions.Builder()
.setSimilarity(0.8)
.setSearchRegions(searchRegions)
.build();

action.perform(findOptions, stateImage);

Click Action

Before

// DEPRECATED - ActionOptions class is deprecated
ActionOptions clickOptions = new ActionOptions.Builder()
.setAction(ActionType.CLICK)
.setClickType(ActionOptions.ClickType.DOUBLE_LEFT)
.setPauseBeforeMouseDown(0.5)
.build();

After

ClickOptions clickOptions = new ClickOptions.Builder()
.setNumberOfClicks(2)
.setPressOptions(new MousePressOptions.Builder()
.setButton(MouseButton.LEFT)
.setPauseBeforeMouseDown(0.5)
.build())
.build();

Type Action

Before

// DEPRECATED - ActionOptions class is deprecated
ActionOptions typeOptions = new ActionOptions.Builder()
.setAction(ActionType.TYPE)
.setTextToType("Hello World")
.setModifierKeys(new String[]{"ctrl", "a"})
.build();

After

TypeOptions typeOptions = new TypeOptions.Builder()
.setText("Hello World")
.setModifierKeys("ctrl", "a")
.build();

Drag Action

Before

// DEPRECATED - ActionOptions class is deprecated
ActionOptions dragOptions = new ActionOptions.Builder()
.setAction(ActionType.DRAG)
.setDragToOffsetX(100)
.setDragToOffsetY(50)
.build();

After

DragOptions dragOptions = new DragOptions.Builder()
.setFromOptions(new PatternFindOptions.Builder()
.setSimilarity(0.9)
.build())
.setToOptions(new PatternFindOptions.Builder()
.setSimilarity(0.9)
.build())
.build();

Key Changes

1. Mouse Button Separation

Mouse button and click count are now separate:

// Before: Combined in ClickType enum
.setClickType(ActionOptions.ClickType.DOUBLE_RIGHT)

// After: Separate configuration
.setNumberOfClicks(2)
.setPressOptions(new MousePressOptions.Builder()
.setButton(MouseButton.RIGHT)
.build())

2. Action Chaining

The new API supports fluent chaining:

ActionConfig findAndClick = new PatternFindOptions.Builder()
.setSimilarity(0.9)
.then(new ClickOptions.Builder()
.setNumberOfClicks(1)
.build())
.build();

3. Verification as Composition

Verification is now composed, not inherited:

ClickOptions clickWithVerification = new ClickOptions.Builder()
.setNumberOfClicks(1)
.setVerificationOptions(new VerificationOptions.Builder()
.setEvent(VerificationOptions.Event.OBJECTS_VANISH)
.setObjectCollection(verifyCollection)
.build())
.build();

4. Drag Returns Movement

Drag operations now return Movement objects instead of regions:

ActionResult result = action.perform(dragOptions, source, target);
Movement movement = result.getMovement().orElse(null);

Step-by-Step Migration

1. Update Imports

Replace:

import io.github.jspinak.brobot.action.ActionOptions; // DEPRECATED

With specific imports:

import io.github.jspinak.brobot.action.ActionType; // For ActionType enum
import io.github.jspinak.brobot.action.basic.click.ClickOptions;
import io.github.jspinak.brobot.action.basic.find.PatternFindOptions;
import io.github.jspinak.brobot.action.basic.type.TypeOptions;
// ... other specific options

2. Replace Builders

Find all new ActionOptions.Builder() and replace with specific builders:

// Find all instances of:
new ActionOptions.Builder().setAction(ActionType.CLICK)

// Replace with:
new ClickOptions.Builder()

3. Update Field Names

  • minScoresimilarity
  • textToTypetext
  • Remove dragToOffsetX/Y (use proper drag configuration)

4. Handle Special Cases

Wait Operations

Wait is no longer an action. Use conditions or pauses:

// Before
// DEPRECATED - ActionOptions class is deprecated
ActionOptions wait = new ActionOptions.Builder()
.setAction(ActionType.WAIT)
.setMaxWait(5)
.build();

// After - use VanishOptions or pause
VanishOptions waitForVanish = new VanishOptions.Builder()
.setTimeout(5.0)
.build();

Custom Find Operations

Replace tempFind with proper find configurations:

// Before
actionOptions.setTempFind(customCollection);

// After
CustomFindOptions customFind = new CustomFindOptions.Builder()
.setCustomCriteria(...)
.build();

Common Pitfalls

  1. Don't instantiate abstract builders: BaseFindOptions.Builder is abstract
  2. MousePressOptions is composed: Don't try to extend it
  3. Check method names: Some have changed (e.g., setTimeoutInSecondssetTimeout)
  4. Verify imports: Make sure you're using the right Options class

Testing Your Migration

After migrating:

  1. Compile: Fix any compilation errors
  2. Test: Run your test suite
  3. Verify: Check that actions behave as expected
  4. Performance: Ensure no performance degradation

Gradual Migration

If you can't migrate everything at once:

  1. The ActionOptionsAdapter provides backward compatibility
  2. Migrate one action type at a time
  3. Test thoroughly after each migration
  4. Remove adapter once fully migrated

Need Help?