class: WidgetLocator

Specialized locators for querying UMG / Slate 2D User Interfaces. Specter taps directly into the Slate Application router. Extends the base SpecterLocator.

Hierarchy & Queries

Methods for finding child widgets and extracting text.

widget.getChild

Traverses down the UMG Widget Tree to find a specific child widget by its designer name.

Usage

const acceptBtn = modal.getChild("AcceptButton", true);

Arguments

  • childNamestring
    The name of the widget in the UMG designer.
  • exactboolean(optional)
    If true, requires a perfect string match. Default: false (contains match).

widget.getText

Extracts the text from a UTextBlock or URichTextBlock.

Usage

const text = await modal.getChild("TitleText").getText();
expect(text).toBe("Are you sure?");

Returns

  • Promise<string>

widget.checkVisibility

Directly queries the Slate rendering pipeline to verify if the widget was actively drawn to the screen on the last frame.

Usage

const isVisible = await modal.checkVisibility();

Returns

  • Promise<boolean>

Input & Navigation

widget.hardwareFocus

Uses an A* spatial heuristic to automatically navigate the UI using simulated analog directional inputs (D-Pad or Joystick) until the widget achieves hardware focus.

Usage

const settingsBtn = world.widget("SettingsButton");
await settingsBtn.hardwareFocus();

Returns

  • Promise<void>

widget.click

Clicks the Slate/UMG widget. Automatically waits for the widget to be visible, enabled, and unoccluded before dispatching click events. A hardware click moves the cursor onto the widget, presses and releases on separate frames (so CommonUI buttons see the hover first), and resolves after the release: the button's handler has already run when await returns. If the game window loses focus mid-click, the click fails with an error instead of passing without effect. If something covers the widget, the error names the widget on top. CommonUI buttons work with both strategies: 'broadcast' goes through the button's own click handling.

Usage

// Hardware Slate mouse click with custom timeout
await acceptBtn.click({ strategy: 'hardware', timeout: 8000 });

// Instant Blueprint delegate dispatch
await acceptBtn.click({ strategy: 'broadcast' });

Arguments

  • optionsObject(optional)
    • strategy'function' | 'hardware' | 'viewport' | 'broadcast'(optional)Defaults to 'function'
      How to click. 'function' runs the button's click handler directly, falling back to a click when there is none. 'hardware' is a real mouse click through Slate and moves the real cursor. 'viewport' hands the click straight to the game's view, as the game reads a player's click, for things the game draws or picks itself. 'broadcast' runs only the click handler (OnClicked, or a CommonUI button's own) and fails when there is none.
    • forceboolean(optional)Defaults to false
      Click even when a player couldn't see the widget. By default every strategy waits until it's visible: it and everything above it are shown, and it's on its switcher's active page.
    • timeoutnumber(optional)Defaults to 5000
      Maximum time in milliseconds to wait for the widget to be actionable before throwing a timeout error.
    • contextstring(optional)
      Optional identifier to distinguish identical click commands in reports and debug logs.

Returns

  • Promise<void>

widget.hardwareAccept

Simulates pressing the standard 'Accept' button (Enter / Gamepad Face Button Bottom) natively through Slate while this widget is focused.

Usage

await acceptBtn.hardwareFocus();
await acceptBtn.hardwareAccept();

Returns

  • Promise<void>

widget.getByTestId

Finds UI inside this widget by a name that stays the same when its words change (see world.getByTestId).

Usage

await world.widget('WBP_PauseMenu').getByTestId('ResumeButton').click();

Arguments

  • testIdstring
    The widget's name or test id.
  • optionsObject(optional)
    { exact?: boolean } (default true).

widget.getByWidget

Same as getChild(): a widget inside this one, by name or class.

Usage

const icon = world.widget('WBP_AbilityBar').getByWidget('WBP_AbilitySlot').nth(0);

Arguments

  • widgetNameOrClassstring
    The child widget's name or class.

widget.getGeometry

Where the widget is on screen: position and center in screen pixels, its size, and whether it's rendered and visible. size is in the widget's own units, before DPI scaling; for maths with position and center, use pixelSize, which is in the same screen pixels. To check that two widgets don't cover each other, use toOverlap().

Usage

const { position, pixelSize } = await button.getGeometry();
const right = position.x + pixelSize.width;
expect(pixelSize.width).toBeGreaterThan(100);

Returns

  • Promise<WidgetGeometry>

widget.waitForStable

Waits until the widget stops moving and resizing, e.g. after a slide-in or scale animation, so a click lands where it should.

Usage

await menu.waitForStable();
await menu.getByTestId('PlayButton').click();

Arguments

  • optionsObject(optional)
    { timeout?: number (default 5000), tolerance?: number in pixels (default 0.5) }.

Returns

  • Promise<void>