@probolabs/playwright 0.4.18 → 0.4.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/dist/index.d.ts +90 -21
- package/dist/index.js +503 -47
- package/dist/index.js.map +1 -1
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/replay-utils.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import { Page } from 'playwright';
|
|
2
|
-
import { PlaywrightAction, ElementTag, ProboLogLevel } from '@probolabs/probo-shared';
|
|
1
|
+
import { Page, Locator } from 'playwright';
|
|
2
|
+
import { PlaywrightAction, ElementTag, PlaywrightTimeoutConfig, AIModel, ServerResponse, ProboLogLevel } from '@probolabs/probo-shared';
|
|
3
3
|
export { ElementInfo, ElementTag, PlaywrightAction, ProboLogLevel } from '@probolabs/probo-shared';
|
|
4
|
+
import { Page as Page$1 } from '@playwright/test';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Execute a given Playwright action, mirroring Python's _perform_action
|
|
7
8
|
*/
|
|
8
|
-
declare function executePlaywrightAction(page: Page, action: PlaywrightAction, value: string, iframe_selector: string, element_css_selector: string): Promise<boolean>;
|
|
9
|
+
declare function executePlaywrightAction(page: Page, action: PlaywrightAction, value: string | boolean, iframe_selector: string, element_css_selector: string): Promise<boolean | string>;
|
|
9
10
|
/**
|
|
10
11
|
* Execute a given Playwright action using native Playwright functions where possible
|
|
11
12
|
*/
|
|
12
|
-
declare function executeCachedPlaywrightAction(page: Page, action: PlaywrightAction, value: string, iframe_selector: string, element_css_selector: string): Promise<boolean>;
|
|
13
|
+
declare function executeCachedPlaywrightAction(page: Page, action: PlaywrightAction, value: string | boolean, iframe_selector: string, element_css_selector: string): Promise<boolean | string>;
|
|
14
|
+
/**
|
|
15
|
+
* Traverses up the DOM from the given locator to find the closest visible ancestor.
|
|
16
|
+
* Returns a Locator for the first visible element found, or null if none is visible up to <html>.
|
|
17
|
+
*
|
|
18
|
+
* @param locator - The Playwright locator to start searching from
|
|
19
|
+
* @returns Promise that resolves to a visible ancestor locator or null if none found
|
|
20
|
+
*/
|
|
21
|
+
declare function findClosestVisibleElement(locator: Locator): Promise<Locator | null>;
|
|
13
22
|
|
|
14
23
|
type ElementTagType = typeof ElementTag[keyof typeof ElementTag];
|
|
15
24
|
declare global {
|
|
@@ -87,22 +96,79 @@ declare class Highlighter {
|
|
|
87
96
|
getMatchingCandidateCached(page: Page): Promise<any>;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
interface RunStepParams extends Partial<PlaywrightTimeoutConfig> {
|
|
100
|
+
iframeSelector: string;
|
|
101
|
+
elementSelector: string;
|
|
102
|
+
action: PlaywrightAction | PlaywrightAction[] | string | string[];
|
|
103
|
+
argument?: string | string[];
|
|
104
|
+
annotation?: string;
|
|
105
|
+
}
|
|
106
|
+
interface RunStepResult {
|
|
107
|
+
key: string;
|
|
108
|
+
value: any;
|
|
109
|
+
}
|
|
110
|
+
declare class ProboPlaywright {
|
|
111
|
+
private readonly config;
|
|
112
|
+
private page;
|
|
113
|
+
constructor(config?: PlaywrightTimeoutConfig, page?: Page$1 | null);
|
|
114
|
+
/**
|
|
115
|
+
* Sets the Playwright page instance for this ProboPlaywright instance.
|
|
116
|
+
* Also applies the configured default navigation and action timeouts to the page.
|
|
117
|
+
*
|
|
118
|
+
* @param page - The Playwright Page instance to use, or null to unset.
|
|
119
|
+
*/
|
|
120
|
+
setPage(page: Page$1 | null): void;
|
|
121
|
+
/**
|
|
122
|
+
* Executes a single step in the test scenario with the specified action on the target element.
|
|
123
|
+
* Handles iframe navigation, element highlighting, and various Playwright actions like click, fill, validate, etc.
|
|
124
|
+
*
|
|
125
|
+
* @param params - Configuration object containing element selectors, action type, arguments, and display options
|
|
126
|
+
* @returns Promise that resolves to a result object for extract actions, or void for other actions
|
|
127
|
+
* @throws Error if element is not found or validation fails
|
|
128
|
+
*/
|
|
129
|
+
runStep(params: RunStepParams): Promise<RunStepResult | void>;
|
|
130
|
+
/**
|
|
131
|
+
* Creates a visual highlight overlay on the target element with optional annotation text.
|
|
132
|
+
* The highlight appears as a red border around the element and can include descriptive text.
|
|
133
|
+
*
|
|
134
|
+
* @param locator - The Playwright locator for the element to highlight
|
|
135
|
+
* @param annotation - Optional text annotation to display above/below the highlighted element
|
|
136
|
+
*/
|
|
137
|
+
private highlight;
|
|
138
|
+
/**
|
|
139
|
+
* Removes the highlight overlay from the target element.
|
|
140
|
+
* Cleans up the visual highlighting created by the highlight method.
|
|
141
|
+
*
|
|
142
|
+
* @param locator - The Playwright locator for the element to unhighlight
|
|
143
|
+
*/
|
|
144
|
+
private unhighlight;
|
|
145
|
+
/**
|
|
146
|
+
* Attempts to fill a form field with the specified value using multiple fallback strategies.
|
|
147
|
+
* First tries the standard fill method, then falls back to click + type if needed.
|
|
148
|
+
*
|
|
149
|
+
* @param locator - The Playwright locator for the input element
|
|
150
|
+
* @param value - The text value to fill into the input field
|
|
151
|
+
*/
|
|
152
|
+
private robustFill;
|
|
153
|
+
/**
|
|
154
|
+
* Performs a robust click operation using multiple fallback strategies.
|
|
155
|
+
* Attempts standard click first, then mouse click at center coordinates, and finally native DOM events.
|
|
156
|
+
*
|
|
157
|
+
* @param locator - The Playwright locator for the element to click
|
|
158
|
+
* @throws Error if all click methods fail
|
|
159
|
+
*/
|
|
160
|
+
private robustClick;
|
|
161
|
+
/**
|
|
162
|
+
* Extracts text content from an element using multiple strategies.
|
|
163
|
+
* Tries textContent first, then inputValue, and finally looks for nested input elements.
|
|
164
|
+
* Returns normalized and trimmed text for consistent comparison.
|
|
165
|
+
*
|
|
166
|
+
* @param locator - The Playwright locator for the element to extract text from
|
|
167
|
+
* @returns Normalized text content with consistent whitespace handling
|
|
168
|
+
*/
|
|
169
|
+
private getTextValue;
|
|
105
170
|
}
|
|
171
|
+
|
|
106
172
|
/**
|
|
107
173
|
* Configuration options for Probo client
|
|
108
174
|
*/
|
|
@@ -128,16 +194,19 @@ declare class Probo {
|
|
|
128
194
|
private readonly scenarioName;
|
|
129
195
|
private readonly aiModel;
|
|
130
196
|
constructor({ scenarioName, token, apiUrl, enableConsoleLogs, logToConsole, logToFile, debugLevel, aiModel }: ProboConfig);
|
|
131
|
-
|
|
197
|
+
askAI(page: Page, question: string): Promise<any>;
|
|
198
|
+
runStep(page: Page, stepPrompt: string, argument?: string | boolean | null, options?: RunStepOptions): Promise<boolean | string>;
|
|
132
199
|
private _handleCachedStep;
|
|
133
200
|
private _handleStepCreation;
|
|
134
201
|
private setupConsoleLogs;
|
|
135
202
|
highlightElements(page: Page, elementTags: [ElementTagType]): Promise<any>;
|
|
136
203
|
unhighlightElements(page: Page): Promise<void>;
|
|
137
204
|
highlightElement(page: Page, element_css_selector: string, iframe_selector: string, element_index: string): Promise<void>;
|
|
205
|
+
waitForMutationsToSettle(page: Page, timeout?: number, initTimeout?: number): Promise<boolean>;
|
|
138
206
|
screenshot(page: Page): Promise<string>;
|
|
139
207
|
private _handlePerformAction;
|
|
208
|
+
askAIHelper(page: Page, question: string): Promise<ServerResponse>;
|
|
140
209
|
}
|
|
141
210
|
|
|
142
|
-
export {
|
|
211
|
+
export { Highlighter, Probo, ProboPlaywright, executeCachedPlaywrightAction, executePlaywrightAction, findClosestVisibleElement };
|
|
143
212
|
export type { ElementTagType, RunStepOptions };
|