Skip to main content

Function: findByTestId()

findByTestId(container, testId, options?): Promise<Widget>

Defined in: queries.ts:476

Finds a single element by test ID (widget name).

Uses the widget's name property as a test identifier. Set via the name prop on GTKX components.

Parameters

ParameterTypeDescription
containerContainerThe container to search within
testIdTextMatchTest ID to match (string, RegExp, or custom matcher)
options?TextMatchOptionsQuery options including normalization and timeout

Returns

Promise<Widget>

Promise resolving to the matching widget

Example

// In component: <GtkButton name="submit-btn" />
const button = await findByTestId(container, "submit-btn");