@probolabs/playwright 1.0.6 → 1.0.10

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 CHANGED
@@ -100,7 +100,6 @@ interface RunStepParams extends Partial<PlaywrightTimeoutConfig> {
100
100
  declare class ProboPlaywright {
101
101
  private readonly config;
102
102
  private page;
103
- private lastNavigationTime;
104
103
  constructor(config?: PlaywrightTimeoutConfig, page?: Page$1 | null);
105
104
  /**
106
105
  * Sets the Playwright page instance for this ProboPlaywright instance.
@@ -109,7 +108,6 @@ declare class ProboPlaywright {
109
108
  * @param page - The Playwright Page instance to use, or null to unset.
110
109
  */
111
110
  setPage(page: Page$1 | null): void;
112
- private onFrameNav;
113
111
  /**
114
112
  * Executes a single step in the test scenario with the specified action on the target element.
115
113
  * Handles iframe navigation, element highlighting, and various Playwright actions like click, fill, validate, etc.
@@ -159,14 +157,21 @@ declare class ProboPlaywright {
159
157
  * @returns Normalized text content with consistent whitespace handling
160
158
  */
161
159
  private getTextValue;
160
+ private setSliderValue;
162
161
  }
163
162
 
164
163
  interface NavTrackerOptions {
165
- stabilizationTimeout?: number;
164
+ waitForStabilityQuietTimeout?: number;
165
+ waitForStabilityInitialDelay?: number;
166
+ waitForStabilityGlobalTimeout?: number;
167
+ pollMs?: number;
168
+ maxInflight?: number;
169
+ inflightGraceMs?: number;
170
+ waitForStabilityVerbose?: boolean;
166
171
  }
167
172
  /**
168
- * Global navigation tracker that monitors page navigation events
169
- * and provides methods to check if navigation has stabilized
173
+ * Global navigation tracker that monitors page navigation events and network activity
174
+ * using CDP (Chrome DevTools Protocol) for comprehensive network monitoring
170
175
  *
171
176
  * This is a singleton class - only one instance can exist at a time
172
177
  */
@@ -175,30 +180,51 @@ declare class NavTracker {
175
180
  private page;
176
181
  private navigationCount;
177
182
  private lastNavTime;
178
- private stabilizationTimeout;
183
+ private waitForStabilityQuietTimeout;
184
+ private waitForStabilityInitialDelay;
185
+ private waitForStabilityGlobalTimeout;
186
+ private pollMs;
187
+ private maxInflight;
188
+ private inflightGraceMs;
189
+ private waitForStabilityVerbose;
179
190
  private isListening;
180
- private onFrameNavHandler;
181
191
  private instanceId;
192
+ private client;
193
+ private inflight;
194
+ private lastHardNavAt;
195
+ private lastSoftNavAt;
196
+ private lastNetworkActivityAt;
197
+ private totalRequestsTracked;
198
+ private readonly RELEVANT_RESOURCE_TYPES;
199
+ private readonly RELEVANT_CONTENT_TYPES;
200
+ private readonly IGNORED_URL_PATTERNS;
182
201
  /**
183
202
  * Private constructor - use getInstance() to get the singleton instance
184
203
  */
185
204
  private constructor();
186
205
  /**
187
- * Start listening for navigation events (private method)
206
+ * Start listening for navigation and network events using CDP (private method)
188
207
  */
189
208
  private start;
190
209
  /**
191
- * Stop listening for navigation events (private method)
210
+ * Stop listening for navigation and network events (private method)
192
211
  */
193
212
  private stop;
194
213
  /**
195
- * Check if navigation has stabilized (no navigation for stabilizationTimeout ms) (private method)
214
+ * Handle network request events
215
+ */
216
+ private onNetworkRequest;
217
+ /**
218
+ * Handle network response events
219
+ */
220
+ private onNetworkResponse;
221
+ /**
222
+ * Check if navigation and network activity has stabilized
196
223
  */
197
224
  private hasNavigationStabilized;
198
225
  /**
199
- * Wait for navigation to stabilize
200
- * Waits a short time to catch any missed navigation events, then ensures
201
- * the latest navigation happened at least stabilizationTimeout ms ago
226
+ * Wait for navigation and network activity to stabilize
227
+ * Uses CDP-based monitoring for comprehensive network activity tracking
202
228
  */
203
229
  waitForNavigationToStabilize(): Promise<void>;
204
230
  /**
@@ -207,7 +233,76 @@ declare class NavTracker {
207
233
  * @param options Optional configuration
208
234
  * @returns The singleton NavTracker instance
209
235
  */
210
- static getInstance(page?: Page, options?: NavTrackerOptions): NavTracker;
236
+ static getInstance(page?: Page, options?: NavTrackerOptions): Promise<NavTracker>;
237
+ /**
238
+ * Reset the singleton instance (useful for testing or page changes)
239
+ */
240
+ static resetInstance(): void;
241
+ }
242
+
243
+ interface MailinatorMessage {
244
+ id: string;
245
+ subject: string;
246
+ from: string;
247
+ origfrom?: string;
248
+ to: string;
249
+ time: number;
250
+ seconds_ago: number;
251
+ domain?: string;
252
+ source?: string;
253
+ parts?: Array<{
254
+ headers: Record<string, string>;
255
+ body: string;
256
+ }>;
257
+ textBody?: string;
258
+ htmlBody?: string;
259
+ }
260
+ /**
261
+ * OTP utility class for working with Mailinator API
262
+ */
263
+ declare class OTP {
264
+ /**
265
+ * Fetches the last messages from Mailinator for a specific inbox
266
+ * @param inbox - The inbox name to check (without @domain)
267
+ * @param since - Unix timestamp to fetch messages since (optional)
268
+ * @returns Promise<MailinatorMessage[]> - Array of messages
269
+ */
270
+ static fetchLastMessages(inbox: string, since?: number): Promise<MailinatorMessage[]>;
271
+ /**
272
+ * Fetches a specific message by ID
273
+ * @param messageId - The message ID
274
+ * @returns Promise<MailinatorMessage> - The message details
275
+ */
276
+ static fetchMessage(messageId: string): Promise<MailinatorMessage>;
277
+ /**
278
+ * Extracts OTP codes from message content
279
+ * @param message - The message to extract OTP from
280
+ * @returns string | null - The OTP code or null if not found
281
+ */
282
+ static extractOTPFromMessage(message: MailinatorMessage): string | null;
283
+ /**
284
+ * Gets the text content from a message for debugging/display purposes
285
+ * @param message - The message to extract text from
286
+ * @returns string - The text content of the message
287
+ */
288
+ static getMessageTextContent(message: MailinatorMessage): string;
289
+ /**
290
+ * Fetches messages from all inboxes in the domain
291
+ * @param limit - Number of messages to fetch (default: 50)
292
+ * @param sort - Sort order: 'ascending' or 'descending' (default: 'descending')
293
+ * @param full - Whether to fetch full message content (default: false)
294
+ * @returns Promise<MailinatorMessage[]> - Array of messages from all inboxes
295
+ */
296
+ static fetchAllInboxMessages(limit?: number, sort?: 'ascending' | 'descending', full?: boolean): Promise<MailinatorMessage[]>;
297
+ /**
298
+ * Waits for an OTP to arrive in the inbox and extracts it
299
+ * @param inbox - The inbox name to monitor (optional - if not provided, searches all inboxes)
300
+ * @param timeout - Maximum time to wait in milliseconds (default: 30000)
301
+ * @param checkInterval - How often to check in milliseconds (default: 1000)
302
+ * @param checkRecentMessagesSinceMs - When > 0, check messages from the last X milliseconds and return the most recent OTP (default: 0)
303
+ * @returns Promise<string | null> - The extracted OTP code or null if timeout/no OTP found
304
+ */
305
+ static waitForOTP(inbox?: string, timeout?: number, checkInterval?: number, checkRecentMessagesSinceMs?: number): Promise<string | null>;
211
306
  }
212
307
 
213
308
  /**
@@ -222,7 +317,7 @@ interface ProboConfig {
222
317
  logToFile?: boolean;
223
318
  debugLevel?: ProboLogLevel;
224
319
  aiModel?: AIModel;
225
- timeoutConfig?: PlaywrightTimeoutConfig;
320
+ timeoutConfig?: Partial<PlaywrightTimeoutConfig>;
226
321
  }
227
322
  interface RunStepOptions {
228
323
  useCache: boolean;
@@ -254,5 +349,5 @@ declare class Probo {
254
349
  askAIHelper(page: Page, question: string): Promise<ServerResponse>;
255
350
  }
256
351
 
257
- export { Highlighter, NavTracker, Probo, ProboPlaywright, findClosestVisibleElement };
258
- export type { ElementTagType, RunStepOptions };
352
+ export { Highlighter, NavTracker, OTP, Probo, ProboPlaywright, findClosestVisibleElement };
353
+ export type { ElementTagType, MailinatorMessage, RunStepOptions };