@probolabs/playwright 1.0.17 → 1.0.20
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/README.md +227 -227
- package/dist/.tsbuildinfo +1 -0
- package/dist/fixtures.cjs +272 -0
- package/dist/fixtures.cjs.map +1 -0
- package/dist/fixtures.js +178 -9
- package/dist/fixtures.js.map +1 -1
- package/dist/index.cjs +4935 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +114 -58
- package/dist/index.js +505 -275
- package/dist/index.js.map +1 -1
- package/dist/types/fixtures.d.ts.map +1 -1
- package/dist/types/highlight.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/replay-utils.d.ts.map +1 -1
- package/loaded_extensions/README.md +23 -23
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Locator, Page } from 'playwright';
|
|
2
|
-
import { ElementTag, PlaywrightTimeoutConfig, PlaywrightAction, AIModel, InitialPageState, FindCandidateInput, ServerResponse
|
|
3
|
-
export { ElementInfo, ElementTag, PlaywrightAction, ProboLogLevel } from '@probolabs/probo-shared';
|
|
2
|
+
import { SmartSelector, ElementTag, ProboLogLevel, PlaywrightTimeoutConfig, PlaywrightAction, TotpConfig, AIModel, InitialPageState, FindCandidateInput, ServerResponse } from '@probolabs/probo-shared';
|
|
3
|
+
export { AIModel, ElementInfo, ElementTag, PlaywrightAction, ProboLogLevel } from '@probolabs/probo-shared';
|
|
4
4
|
import { Page as Page$1 } from '@playwright/test';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -24,8 +24,10 @@ declare global {
|
|
|
24
24
|
highlightElements: (elements: Array<{
|
|
25
25
|
css_selector: string;
|
|
26
26
|
iframe_selector: string;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
smart_selector: SmartSelector | null;
|
|
28
|
+
smart_iframe_selector: SmartSelector | null;
|
|
29
|
+
index: number;
|
|
30
|
+
}>, enableSmartSelectors: boolean) => void;
|
|
29
31
|
unhighlightElements: () => void;
|
|
30
32
|
findElements: (elementTypes: string) => any[];
|
|
31
33
|
getElementInfo: (element: Element, index: number) => any;
|
|
@@ -34,7 +36,7 @@ declare global {
|
|
|
34
36
|
actual?: any;
|
|
35
37
|
matchingCandidate?: any;
|
|
36
38
|
findAndCacheCandidateElements?: (elementTypes: string[]) => number;
|
|
37
|
-
findAndCacheActualElement?: (
|
|
39
|
+
findAndCacheActualElement?: (iframeSelector: string | SmartSelector, elementSelector: string | SmartSelector, isHover: boolean, useSmartSelectors: boolean) => boolean;
|
|
38
40
|
findAndCacheMatchingCandidate?: () => boolean;
|
|
39
41
|
highlightCachedElements?: (which: 'candidates' | 'actual' | 'matching') => void;
|
|
40
42
|
unhighlight?: () => void;
|
|
@@ -42,16 +44,19 @@ declare global {
|
|
|
42
44
|
getCandidates?: () => any[];
|
|
43
45
|
getActual?: () => any;
|
|
44
46
|
getMatchingCandidate?: () => any;
|
|
47
|
+
setLoggerDebugLevel?: (debugLevel: ProboLogLevel) => void;
|
|
45
48
|
};
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
declare class Highlighter {
|
|
49
|
-
private
|
|
50
|
-
|
|
52
|
+
private readonly enableSmartSelectors;
|
|
53
|
+
private readonly enableConsoleLogs;
|
|
54
|
+
private readonly debugLevel;
|
|
55
|
+
constructor(enableSmartSelectors?: boolean, enableConsoleLogs?: boolean, debugLevel?: ProboLogLevel);
|
|
51
56
|
private ensureHighlighterScript;
|
|
52
57
|
highlightElements(page: Page, elementTags: [ElementTagType]): Promise<any>;
|
|
53
58
|
unhighlightElements(page: Page): Promise<void>;
|
|
54
|
-
highlightElement(page: Page, element_css_selector: string, iframe_selector: string, element_index:
|
|
59
|
+
highlightElement(page: Page, element_css_selector: string, iframe_selector: string, smart_selector: SmartSelector | null, smart_iframe_selector: SmartSelector | null, element_index: number): Promise<void>;
|
|
55
60
|
/**
|
|
56
61
|
* Find and cache candidate elements of a given type (e.g., 'CLICKABLE').
|
|
57
62
|
* Returns the number of candidates found.
|
|
@@ -61,7 +66,7 @@ declare class Highlighter {
|
|
|
61
66
|
* Find and cache the actual interaction element by CSS and iframe selector.
|
|
62
67
|
* Returns true if found, false otherwise.
|
|
63
68
|
*/
|
|
64
|
-
findAndCacheActualElement(page: Page,
|
|
69
|
+
findAndCacheActualElement(page: Page, iframeSelector: string | SmartSelector, elementSelector: string | SmartSelector, isHover?: boolean): Promise<boolean>;
|
|
65
70
|
/**
|
|
66
71
|
* Find and cache the best matching candidate for the actual element.
|
|
67
72
|
* Returns true if a match was found, false otherwise.
|
|
@@ -91,73 +96,106 @@ declare class Highlighter {
|
|
|
91
96
|
interface RunStepParams extends Partial<PlaywrightTimeoutConfig> {
|
|
92
97
|
iframeSelector?: string;
|
|
93
98
|
elementSelector?: string;
|
|
99
|
+
smartSelector?: SmartSelector | null;
|
|
100
|
+
smartIFrameSelector?: SmartSelector | null;
|
|
94
101
|
action: PlaywrightAction;
|
|
95
102
|
argument?: string | string[];
|
|
96
103
|
annotation?: string;
|
|
97
104
|
pollingInterval?: number;
|
|
98
105
|
timeout?: number;
|
|
106
|
+
totpConfig?: TotpConfig;
|
|
107
|
+
}
|
|
108
|
+
interface ProboPlaywrightConfig {
|
|
109
|
+
timeoutConfig?: Partial<PlaywrightTimeoutConfig>;
|
|
110
|
+
enableSmartSelectors?: boolean;
|
|
111
|
+
debugLevel?: ProboLogLevel;
|
|
99
112
|
}
|
|
100
113
|
declare class ProboPlaywright {
|
|
114
|
+
private readonly enableSmartSelectors;
|
|
101
115
|
private readonly timeoutConfig;
|
|
102
116
|
private page;
|
|
103
|
-
|
|
117
|
+
private params;
|
|
118
|
+
constructor({ enableSmartSelectors, timeoutConfig, debugLevel }: ProboPlaywrightConfig, page?: Page$1 | null);
|
|
104
119
|
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
120
|
+
* Sets the Playwright page instance for this ProboPlaywright instance.
|
|
121
|
+
* Also applies the configured default navigation and action timeouts to the page.
|
|
122
|
+
*
|
|
123
|
+
* @param page - The Playwright Page instance to use, or null to unset.
|
|
124
|
+
*/
|
|
110
125
|
setPage(page: Page$1 | null): void;
|
|
126
|
+
/**
|
|
127
|
+
* Sets the parameters object for template literal interpolation
|
|
128
|
+
* Stores a reference to the params object so mutations are automatically reflected
|
|
129
|
+
* @param params The parameters object containing values to use for interpolation
|
|
130
|
+
*/
|
|
131
|
+
setParams(params: Record<string, any>): void;
|
|
132
|
+
/**
|
|
133
|
+
* Interpolates a string using the current params and optional additional context
|
|
134
|
+
* @param str The string to interpolate (may contain ${variable} syntax)
|
|
135
|
+
* @param additionalContext Optional additional context to merge with params
|
|
136
|
+
* @returns The interpolated string
|
|
137
|
+
*/
|
|
138
|
+
private interpolate;
|
|
111
139
|
/**
|
|
112
140
|
* Executes a single step in the test scenario with the specified action on the target element.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
141
|
+
* Handles iframe navigation, element highlighting, and various Playwright actions like click, fill, validate, etc.
|
|
142
|
+
*
|
|
143
|
+
* @param params - Configuration object containing element selectors, action type, arguments, and display options
|
|
144
|
+
* @returns Promise that resolves to a string for extract actions, boolean for assert actions, or void for other actions
|
|
145
|
+
* @throws Error if element is not found or validation fails
|
|
146
|
+
*/
|
|
147
|
+
runStep(params: RunStepParams): Promise<string | boolean | void>;
|
|
148
|
+
/**
|
|
149
|
+
* Public method to generate TOTP code using the provided secret, digits, and algorithm
|
|
150
|
+
* @param secret - The TOTP secret (base32 encoded)
|
|
151
|
+
* @param digits - Number of digits in the TOTP code (default: 6)
|
|
152
|
+
* @param algorithm - Hash algorithm to use (default: 'SHA1')
|
|
153
|
+
* @returns The generated TOTP code
|
|
118
154
|
*/
|
|
119
|
-
runStep(params: RunStepParams): Promise<string | void>;
|
|
120
155
|
generateOTP(secret: string, digits?: number, algorithm?: string): string;
|
|
156
|
+
private getLocator;
|
|
157
|
+
private getLocatorOrFrame;
|
|
121
158
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
159
|
+
* Creates a visual highlight overlay on the target element with optional annotation text.
|
|
160
|
+
* The highlight appears as a red border around the element and can include descriptive text.
|
|
161
|
+
*
|
|
162
|
+
* @param locator - The Playwright locator for the element to highlight
|
|
163
|
+
* @param annotation - Optional text annotation to display above/below the highlighted element
|
|
164
|
+
*/
|
|
128
165
|
private highlight;
|
|
129
166
|
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
167
|
+
* Removes the highlight overlay from the target element.
|
|
168
|
+
* Cleans up the visual highlighting created by the highlight method.
|
|
169
|
+
*
|
|
170
|
+
* @param locator - The Playwright locator for the element to unhighlight
|
|
171
|
+
*/
|
|
135
172
|
private unhighlight;
|
|
136
173
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
174
|
+
* Attempts to fill a form field with the specified value using multiple fallback strategies.
|
|
175
|
+
* First tries the standard fill method, then falls back to click + type if needed.
|
|
176
|
+
*
|
|
177
|
+
* @param locator - The Playwright locator for the input element
|
|
178
|
+
* @param value - The text value to fill into the input field
|
|
179
|
+
*/
|
|
143
180
|
private robustFill;
|
|
144
181
|
private robustTypeKeys;
|
|
145
182
|
/**
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
183
|
+
* Performs a robust mouse action (click or hover) using multiple fallback strategies.
|
|
184
|
+
* Attempts standard click first, then mouse click at center coordinates, and finally native DOM events.
|
|
185
|
+
*
|
|
186
|
+
* @param locator - The Playwright locator for the element to click
|
|
187
|
+
* @param action - The mouse action to perform ('click' or 'hover')
|
|
188
|
+
* @throws Error if all mouse action methods fail
|
|
189
|
+
*/
|
|
190
|
+
private robustMouseAction;
|
|
191
|
+
/**
|
|
192
|
+
* Extracts text content from an element using multiple strategies.
|
|
193
|
+
* Tries textContent first, then inputValue, and finally looks for nested input elements.
|
|
194
|
+
* Returns normalized and trimmed text for consistent comparison.
|
|
195
|
+
*
|
|
196
|
+
* @param locator - The Playwright locator for the element to extract text from
|
|
197
|
+
* @returns Normalized text content with consistent whitespace handling
|
|
198
|
+
*/
|
|
161
199
|
private getTextValue;
|
|
162
200
|
private setSliderValue;
|
|
163
201
|
}
|
|
@@ -332,6 +370,7 @@ interface ProboConfig {
|
|
|
332
370
|
scenarioName: string;
|
|
333
371
|
token?: string;
|
|
334
372
|
apiUrl?: string;
|
|
373
|
+
enableSmartSelectors?: boolean;
|
|
335
374
|
enableConsoleLogs?: boolean;
|
|
336
375
|
logToConsole?: boolean;
|
|
337
376
|
logToFile?: boolean;
|
|
@@ -348,27 +387,44 @@ interface AskAIOptions {
|
|
|
348
387
|
stepId?: number;
|
|
349
388
|
createStep?: boolean;
|
|
350
389
|
}
|
|
390
|
+
|
|
351
391
|
declare class Probo {
|
|
352
392
|
private highlighter;
|
|
353
393
|
private apiClient;
|
|
394
|
+
private readonly debugLevel;
|
|
354
395
|
private readonly enableConsoleLogs;
|
|
355
396
|
private readonly scenarioName;
|
|
356
397
|
private readonly aiModel;
|
|
398
|
+
private readonly enableSmartSelectors;
|
|
357
399
|
private readonly timeoutConfig;
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
400
|
+
private params;
|
|
401
|
+
constructor({ scenarioName, token, apiUrl, enableConsoleLogs, enableSmartSelectors, logToConsole, logToFile, debugLevel, aiModel, timeoutConfig }: ProboConfig);
|
|
402
|
+
/**
|
|
403
|
+
* Sets the parameters object for template literal interpolation
|
|
404
|
+
* Stores a reference to the params object so mutations are automatically reflected
|
|
405
|
+
* @param params The parameters object containing values to use for interpolation
|
|
406
|
+
*/
|
|
407
|
+
setParams(params: Record<string, any>): void;
|
|
408
|
+
/**
|
|
409
|
+
* Interpolates a string using the current params and optional additional context
|
|
410
|
+
* @param str The string to interpolate (may contain ${variable} syntax)
|
|
411
|
+
* @param additionalContext Optional additional context to merge with params
|
|
412
|
+
* @returns The interpolated string
|
|
413
|
+
*/
|
|
414
|
+
private interpolate;
|
|
415
|
+
askAI(page: Page, question: string, options: AskAIOptions, assertAnswer?: string): Promise<any>;
|
|
416
|
+
runStep(page: Page, stepPrompt: string, argument?: string | boolean | null, options?: RunStepOptions): Promise<string | boolean | void>;
|
|
361
417
|
private _handleCachedStep;
|
|
362
418
|
private setupConsoleLogs;
|
|
363
419
|
getInitialPageState(page: Page): Promise<InitialPageState>;
|
|
364
420
|
findAndHighlightCandidateElements(page: Page, elementTags: string[]): Promise<FindCandidateInput>;
|
|
365
421
|
highlightElements(page: Page, elementTags: [ElementTagType]): Promise<any>;
|
|
366
422
|
unhighlightElements(page: Page): Promise<void>;
|
|
367
|
-
highlightElement(page: Page, element_css_selector: string, iframe_selector: string, element_index:
|
|
423
|
+
highlightElement(page: Page, element_css_selector: string, iframe_selector: string, smart_selector: SmartSelector | null, smart_iframe_selector: SmartSelector | null, element_index: number): Promise<void>;
|
|
368
424
|
waitForMutationsToSettle(page: Page, timeout?: number, initTimeout?: number): Promise<boolean>;
|
|
369
425
|
screenshot(page: Page): Promise<string>;
|
|
370
426
|
private _handlePerformAction;
|
|
371
|
-
askAIHelper(page: Page, question: string, options: AskAIOptions): Promise<ServerResponse>;
|
|
427
|
+
askAIHelper(page: Page, question: string, options: AskAIOptions, assertAnswer?: string): Promise<ServerResponse>;
|
|
372
428
|
}
|
|
373
429
|
|
|
374
430
|
export { Highlighter, NavTracker, OTP, Probo, ProboPlaywright, findClosestVisibleElement };
|