@specter-automation/test 1.0.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/component-registry.d.ts +12 -0
- package/dist/core/component-registry.js +25 -0
- package/dist/core/conditions/input-conditions.d.ts +81 -0
- package/dist/core/conditions/input-conditions.js +197 -0
- package/dist/core/events.d.ts +133 -0
- package/dist/core/events.js +6 -0
- package/dist/core/locators/actor-locator.d.ts +425 -0
- package/dist/core/locators/actor-locator.js +1006 -0
- package/dist/core/locators/ai-controller-locator.d.ts +6 -0
- package/dist/core/locators/ai-controller-locator.js +19 -0
- package/dist/core/locators/index.d.ts +6 -0
- package/dist/core/locators/index.js +22 -0
- package/dist/core/locators/movement-locator.d.ts +27 -0
- package/dist/core/locators/movement-locator.js +78 -0
- package/dist/core/locators/skeleton-locator.d.ts +13 -0
- package/dist/core/locators/skeleton-locator.js +35 -0
- package/dist/core/locators/specter-locator.d.ts +110 -0
- package/dist/core/locators/specter-locator.js +323 -0
- package/dist/core/locators/widget-locator.d.ts +104 -0
- package/dist/core/locators/widget-locator.js +297 -0
- package/dist/core/specter-client.d.ts +352 -0
- package/dist/core/specter-client.js +883 -0
- package/dist/core/specter-input-sequence.d.ts +96 -0
- package/dist/core/specter-input-sequence.js +180 -0
- package/dist/core/specter-keyboard.d.ts +21 -0
- package/dist/core/specter-keyboard.js +63 -0
- package/dist/core/specter-keys.d.ts +1 -0
- package/dist/core/specter-keys.js +2 -0
- package/dist/core/specter-network.d.ts +34 -0
- package/dist/core/specter-network.js +59 -0
- package/dist/core/specter-reporter.d.ts +23 -0
- package/dist/core/specter-reporter.js +403 -0
- package/dist/core/test-wrapper.d.ts +25 -0
- package/dist/core/test-wrapper.js +200 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +29 -0
- package/dist/matchers/actor-matchers.d.ts +492 -0
- package/dist/matchers/actor-matchers.js +841 -0
- package/dist/matchers/gas-matchers.d.ts +198 -0
- package/dist/matchers/gas-matchers.js +539 -0
- package/dist/matchers/locator-matchers.d.ts +80 -0
- package/dist/matchers/locator-matchers.js +214 -0
- package/dist/matchers/material-matchers.d.ts +74 -0
- package/dist/matchers/material-matchers.js +295 -0
- package/dist/matchers/widget-matchers.d.ts +81 -0
- package/dist/matchers/widget-matchers.js +110 -0
- package/package.json +33 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { SpecterLocator } from "../locators/specter-locator";
|
|
2
|
+
import { ClickOptions } from "../specter-client";
|
|
3
|
+
import { WidgetEventMap, EventPredicate, WaitForEventOptions } from "../events";
|
|
4
|
+
export type WidgetRole = 'button' | 'textbox' | 'checkbox' | 'slider' | 'text' | 'heading' | 'label' | 'image' | 'combobox' | 'dropdown' | 'progressbar';
|
|
5
|
+
export interface WidgetRoleOptions {
|
|
6
|
+
name?: string | RegExp;
|
|
7
|
+
exact?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface WidgetGeometry {
|
|
10
|
+
isRendered: boolean;
|
|
11
|
+
isVisible: boolean;
|
|
12
|
+
position: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
size: {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
center: {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare class WidgetLocator<T = any> extends SpecterLocator<T> {
|
|
26
|
+
waitForEvent<K extends keyof WidgetEventMap>(eventName: K | (string & {}), optionsOrPredicate?: number | EventPredicate<K extends keyof WidgetEventMap ? WidgetEventMap[K] : any> | WaitForEventOptions<K extends keyof WidgetEventMap ? WidgetEventMap[K] : any>): Promise<K extends keyof WidgetEventMap ? WidgetEventMap[K] : any>;
|
|
27
|
+
/**
|
|
28
|
+
* Finds a child widget by its semantic role (button, textbox, checkbox, slider, text, image, combobox)
|
|
29
|
+
* and optional accessible name / text label.
|
|
30
|
+
*/
|
|
31
|
+
getByRole(role: WidgetRole | string, options?: WidgetRoleOptions): WidgetLocator;
|
|
32
|
+
/**
|
|
33
|
+
* Finds a child widget containing the specified text string or regex.
|
|
34
|
+
*/
|
|
35
|
+
getByText(text: string | RegExp, options?: {
|
|
36
|
+
exact?: boolean;
|
|
37
|
+
}): WidgetLocator;
|
|
38
|
+
/**
|
|
39
|
+
* Alias for getChild / navigating down the widget hierarchy.
|
|
40
|
+
*/
|
|
41
|
+
getByWidget(widgetNameOrClass: string): WidgetLocator;
|
|
42
|
+
/**
|
|
43
|
+
* Traverses down the UMG Widget Tree to find a child widget.
|
|
44
|
+
* @param childName The name of the widget in the designer.
|
|
45
|
+
* @param exact If true, requires a perfect string match (ignoring case). If false, does a fuzzy 'contains' match.
|
|
46
|
+
*/
|
|
47
|
+
getChild(childName: string, exact?: boolean): WidgetLocator;
|
|
48
|
+
/**
|
|
49
|
+
* Types or fills text into an editable text box (UEditableTextBox, UEditableText, UMultiLineEditableTextBox, USpinBox).
|
|
50
|
+
* Automatically dispatches OnTextChanged and OnTextCommitted events.
|
|
51
|
+
*/
|
|
52
|
+
fill(value: string, options?: {
|
|
53
|
+
timeout?: number;
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Hovers the hardware Slate cursor over the center of the widget geometry.
|
|
57
|
+
*/
|
|
58
|
+
hover(options?: {
|
|
59
|
+
timeout?: number;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves the screen-space bounding geometry (position, size, center, visibility) of this widget.
|
|
63
|
+
*/
|
|
64
|
+
getGeometry(): Promise<WidgetGeometry>;
|
|
65
|
+
/**
|
|
66
|
+
* Waits until the widget's bounding box and screen-space position have stopped moving
|
|
67
|
+
* (e.g. menu transition, slide-in animation, or scaling has completed).
|
|
68
|
+
*/
|
|
69
|
+
waitForStable(options?: {
|
|
70
|
+
timeout?: number;
|
|
71
|
+
tolerance?: number;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Clicks the widget. Retries until the widget is rendered, constructed, and successfully clicked, or until timeout.
|
|
75
|
+
* @param options.strategy 'function' (Default, direct programmatic invocation) or 'hardware' (physical Slate mouse click) or 'broadcast'
|
|
76
|
+
* @param options.timeout How long to wait for the click to succeed before failing (default: 5000ms)
|
|
77
|
+
* @param options.tolerance Pixel threshold for stability detection when using hardware click (default: 0.5px)
|
|
78
|
+
* @param options.waitForStable Whether to wait for animations to stop before clicking with hardware (default: true)
|
|
79
|
+
* @param options.context Optional string to distinguish identical commands in the UI
|
|
80
|
+
*/
|
|
81
|
+
click(options?: {
|
|
82
|
+
timeout?: number;
|
|
83
|
+
context?: string;
|
|
84
|
+
} & ClickOptions): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Extracts the text from a UTextBlock or URichTextBlock.
|
|
87
|
+
*/
|
|
88
|
+
getText(): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* Queries the UMG Slate system to see if the widget is actively drawn on screen.
|
|
91
|
+
*/
|
|
92
|
+
isEnabled(): Promise<boolean>;
|
|
93
|
+
checkVisibility(): Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Calculates the A* path and moves hardware focus to the widget.
|
|
96
|
+
* This Promise resolves ONLY when the engine confirms the widget has received focus.
|
|
97
|
+
*/
|
|
98
|
+
hardwareFocus(): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Simulates pressing the standard "Accept" button (Enter / Gamepad Face Button Bottom)
|
|
101
|
+
* natively through Slate while this widget is focused.
|
|
102
|
+
*/
|
|
103
|
+
hardwareAccept(): Promise<void>;
|
|
104
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.WidgetLocator = void 0;
|
|
37
|
+
const specter_locator_1 = require("../locators/specter-locator");
|
|
38
|
+
const test_1 = __importStar(require("@playwright/test"));
|
|
39
|
+
class WidgetLocator extends specter_locator_1.SpecterLocator {
|
|
40
|
+
async waitForEvent(eventName, optionsOrPredicate) {
|
|
41
|
+
return super.waitForEvent(eventName, optionsOrPredicate);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Finds a child widget by its semantic role (button, textbox, checkbox, slider, text, image, combobox)
|
|
45
|
+
* and optional accessible name / text label.
|
|
46
|
+
*/
|
|
47
|
+
getByRole(role, options) {
|
|
48
|
+
const rolePayload = JSON.stringify({
|
|
49
|
+
role,
|
|
50
|
+
name: options?.name instanceof RegExp ? options.name.source : options?.name || '',
|
|
51
|
+
exact: options?.exact ?? (typeof options?.name === 'string' ? true : false)
|
|
52
|
+
});
|
|
53
|
+
const newPipeline = [
|
|
54
|
+
...this.pipeline,
|
|
55
|
+
{ action: 'getWidgetByRole', value: rolePayload, exact: options?.exact }
|
|
56
|
+
];
|
|
57
|
+
return new WidgetLocator(this.transport, newPipeline);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Finds a child widget containing the specified text string or regex.
|
|
61
|
+
*/
|
|
62
|
+
getByText(text, options) {
|
|
63
|
+
const textStr = text instanceof RegExp ? text.source : text;
|
|
64
|
+
const exactMatch = options?.exact ?? (typeof text === 'string' ? true : false);
|
|
65
|
+
const newPipeline = [
|
|
66
|
+
...this.pipeline,
|
|
67
|
+
{ action: 'getWidgetByText', value: textStr, exact: exactMatch }
|
|
68
|
+
];
|
|
69
|
+
return new WidgetLocator(this.transport, newPipeline);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Alias for getChild / navigating down the widget hierarchy.
|
|
73
|
+
*/
|
|
74
|
+
getByWidget(widgetNameOrClass) {
|
|
75
|
+
return this.getChild(widgetNameOrClass);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Traverses down the UMG Widget Tree to find a child widget.
|
|
79
|
+
* @param childName The name of the widget in the designer.
|
|
80
|
+
* @param exact If true, requires a perfect string match (ignoring case). If false, does a fuzzy 'contains' match.
|
|
81
|
+
*/
|
|
82
|
+
getChild(childName, exact = false) {
|
|
83
|
+
const newPipeline = [
|
|
84
|
+
...this.pipeline,
|
|
85
|
+
{ action: 'getChildWidget', value: childName, exact: exact }
|
|
86
|
+
];
|
|
87
|
+
return new WidgetLocator(this.transport, newPipeline);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Types or fills text into an editable text box (UEditableTextBox, UEditableText, UMultiLineEditableTextBox, USpinBox).
|
|
91
|
+
* Automatically dispatches OnTextChanged and OnTextCommitted events.
|
|
92
|
+
*/
|
|
93
|
+
async fill(value, options) {
|
|
94
|
+
const baseName = `Fill Widget @ ${this.toString()}`;
|
|
95
|
+
return await test_1.default.step(baseName, async () => {
|
|
96
|
+
const timeout = options?.timeout ?? 5000;
|
|
97
|
+
const startTime = Date.now();
|
|
98
|
+
let lastError = null;
|
|
99
|
+
while (Date.now() - startTime < timeout) {
|
|
100
|
+
try {
|
|
101
|
+
const response = await this.evaluate("FillWidget", { value }, undefined, true);
|
|
102
|
+
if (response?.status === 'success') {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
lastError = new Error(response?.error || 'FillWidget failed');
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
lastError = err;
|
|
109
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
110
|
+
if (msg.toLowerCase().includes('strict mode')) {
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
115
|
+
}
|
|
116
|
+
const details = lastError ? `\nUnderlying Error: ${lastError.message}` : '';
|
|
117
|
+
throw new Error(`[Specter Timeout] Timed out after ${timeout}ms attempting to fill widget: ${this.toString()}.${details}`);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Hovers the hardware Slate cursor over the center of the widget geometry.
|
|
122
|
+
*/
|
|
123
|
+
async hover(options) {
|
|
124
|
+
const baseName = `Hover Widget @ ${this.toString()}`;
|
|
125
|
+
return await test_1.default.step(baseName, async () => {
|
|
126
|
+
const timeout = options?.timeout ?? 5000;
|
|
127
|
+
const startTime = Date.now();
|
|
128
|
+
let lastError = null;
|
|
129
|
+
while (Date.now() - startTime < timeout) {
|
|
130
|
+
try {
|
|
131
|
+
const response = await this.evaluate("HoverWidget", {}, undefined, true);
|
|
132
|
+
if (response?.status === 'success') {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
lastError = new Error(response?.error || 'HoverWidget failed');
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
lastError = err;
|
|
139
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
140
|
+
if (msg.toLowerCase().includes('strict mode')) {
|
|
141
|
+
throw err;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
145
|
+
}
|
|
146
|
+
const details = lastError ? `\nUnderlying Error: ${lastError.message}` : '';
|
|
147
|
+
throw new Error(`[Specter Timeout] Timed out after ${timeout}ms attempting to hover widget: ${this.toString()}.${details}`);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Retrieves the screen-space bounding geometry (position, size, center, visibility) of this widget.
|
|
152
|
+
*/
|
|
153
|
+
async getGeometry() {
|
|
154
|
+
const response = await this.evaluate("GetWidgetGeometry", {}, undefined, true);
|
|
155
|
+
if (response.status !== 'success') {
|
|
156
|
+
throw new Error(`Failed to get widget geometry: ${response.error}`);
|
|
157
|
+
}
|
|
158
|
+
return response.data;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Waits until the widget's bounding box and screen-space position have stopped moving
|
|
162
|
+
* (e.g. menu transition, slide-in animation, or scaling has completed).
|
|
163
|
+
*/
|
|
164
|
+
async waitForStable(options) {
|
|
165
|
+
const timeout = options?.timeout ?? 5000;
|
|
166
|
+
const tolerance = options?.tolerance ?? 0.5;
|
|
167
|
+
const startTime = Date.now();
|
|
168
|
+
let prevCenter = null;
|
|
169
|
+
let prevSize = null;
|
|
170
|
+
while (Date.now() - startTime < timeout) {
|
|
171
|
+
const geo = await this.getGeometry();
|
|
172
|
+
if (prevCenter && prevSize) {
|
|
173
|
+
const dx = Math.abs(geo.center.x - prevCenter.x);
|
|
174
|
+
const dy = Math.abs(geo.center.y - prevCenter.y);
|
|
175
|
+
const dw = Math.abs(geo.size.width - prevSize.width);
|
|
176
|
+
const dh = Math.abs(geo.size.height - prevSize.height);
|
|
177
|
+
if (dx <= tolerance && dy <= tolerance && dw <= tolerance && dh <= tolerance) {
|
|
178
|
+
return; // Stable!
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
prevCenter = geo.center;
|
|
182
|
+
prevSize = geo.size;
|
|
183
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
184
|
+
}
|
|
185
|
+
throw new Error(`Timed out after ${timeout}ms waiting for widget to be stable (stop moving/animating).`);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Clicks the widget. Retries until the widget is rendered, constructed, and successfully clicked, or until timeout.
|
|
189
|
+
* @param options.strategy 'function' (Default, direct programmatic invocation) or 'hardware' (physical Slate mouse click) or 'broadcast'
|
|
190
|
+
* @param options.timeout How long to wait for the click to succeed before failing (default: 5000ms)
|
|
191
|
+
* @param options.tolerance Pixel threshold for stability detection when using hardware click (default: 0.5px)
|
|
192
|
+
* @param options.waitForStable Whether to wait for animations to stop before clicking with hardware (default: true)
|
|
193
|
+
* @param options.context Optional string to distinguish identical commands in the UI
|
|
194
|
+
*/
|
|
195
|
+
async click(options) {
|
|
196
|
+
// 1. Format the name to use the new Playwright "Subtitle" delimiter
|
|
197
|
+
const baseName = `Click Widget @ ${this.toString()}`;
|
|
198
|
+
const stepName = options?.context ? `${baseName} [${options?.context}]` : baseName;
|
|
199
|
+
// 2. Wrap the ENTIRE sequence in a high-level step!
|
|
200
|
+
return await test_1.default.step(stepName, async () => {
|
|
201
|
+
const strategy = options?.strategy || 'function';
|
|
202
|
+
const timeout = options?.timeout ?? 5000;
|
|
203
|
+
const startTime = Date.now();
|
|
204
|
+
let lastError = null;
|
|
205
|
+
// Actionability check: if using hardware click, wait for motion/animation to stabilize
|
|
206
|
+
if (strategy === 'hardware' && options?.waitForStable !== false) {
|
|
207
|
+
await this.waitForStable({ timeout: options?.timeout, tolerance: options?.tolerance });
|
|
208
|
+
}
|
|
209
|
+
while (Date.now() - startTime < timeout) {
|
|
210
|
+
try {
|
|
211
|
+
const response = await this.evaluate('ClickWidget', { strategy }, undefined, true);
|
|
212
|
+
if (response?.status === 'success') {
|
|
213
|
+
return; // Successfully clicked!
|
|
214
|
+
}
|
|
215
|
+
lastError = new Error(response?.error || 'ClickWidget failed');
|
|
216
|
+
}
|
|
217
|
+
catch (err) {
|
|
218
|
+
lastError = err;
|
|
219
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
220
|
+
if (msg.toLowerCase().includes('strict mode')) {
|
|
221
|
+
throw err;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
225
|
+
}
|
|
226
|
+
const details = lastError ? `\nUnderlying Error: ${lastError.message}` : '';
|
|
227
|
+
throw new Error(`[Specter Timeout] Timed out after ${timeout}ms attempting to click widget: ${this.toString()}.${details}`);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Extracts the text from a UTextBlock or URichTextBlock.
|
|
232
|
+
*/
|
|
233
|
+
async getText() {
|
|
234
|
+
const response = await this.evaluate("GetWidgetText", {});
|
|
235
|
+
if (response.status !== 'success') {
|
|
236
|
+
throw new Error(`Failed to get widget text: ${response.error}`);
|
|
237
|
+
}
|
|
238
|
+
return response.data.text;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Queries the UMG Slate system to see if the widget is actively drawn on screen.
|
|
242
|
+
*/
|
|
243
|
+
async isEnabled() {
|
|
244
|
+
const response = await this.evaluate("IsWidgetEnabled", {});
|
|
245
|
+
return response.data.isEnabled;
|
|
246
|
+
}
|
|
247
|
+
async checkVisibility() {
|
|
248
|
+
try {
|
|
249
|
+
const response = await this.evaluate("CheckWidgetVisibility", {}, undefined, true);
|
|
250
|
+
return response?.data?.isVisible === true;
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
254
|
+
if (msg.toLowerCase().includes('strict mode')) {
|
|
255
|
+
throw e;
|
|
256
|
+
}
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Calculates the A* path and moves hardware focus to the widget.
|
|
262
|
+
* This Promise resolves ONLY when the engine confirms the widget has received focus.
|
|
263
|
+
*/
|
|
264
|
+
async hardwareFocus() {
|
|
265
|
+
await test_1.default.step(`Specter UI: Hardware Focus`, async () => {
|
|
266
|
+
const response = await this.transport.sendCommand({
|
|
267
|
+
command: 'NavigateToWidget',
|
|
268
|
+
locatorPipeline: this.pipeline
|
|
269
|
+
});
|
|
270
|
+
if (response.status === 'error')
|
|
271
|
+
throw new Error(`[Specter] Pathfinding failed: ${response.error}`);
|
|
272
|
+
// Poll the engine until the focus state changes
|
|
273
|
+
await (0, test_1.expect)(async () => {
|
|
274
|
+
const checkResponse = await this.evaluate("CheckIsFocused", {});
|
|
275
|
+
// If C++ says it isn't focused yet, throw the C++ error message up to Playwright.
|
|
276
|
+
// expect.toPass() will catch this error and automatically retry the block!
|
|
277
|
+
if (checkResponse.status === 'error') {
|
|
278
|
+
throw new Error(checkResponse.error);
|
|
279
|
+
}
|
|
280
|
+
}).toPass({ timeout: 5000 });
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Simulates pressing the standard "Accept" button (Enter / Gamepad Face Button Bottom)
|
|
285
|
+
* natively through Slate while this widget is focused.
|
|
286
|
+
*/
|
|
287
|
+
async hardwareAccept() {
|
|
288
|
+
await test_1.default.step(`Specter UI: Hardware Accept`, async () => {
|
|
289
|
+
await this.transport.sendCommand({
|
|
290
|
+
command: 'ConsoleCommand',
|
|
291
|
+
locatorPipeline: [], // Global console command
|
|
292
|
+
payload: { command: 'keystroke Enter' }
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
exports.WidgetLocator = WidgetLocator;
|