@probolabs/playwright 1.0.4 → 1.0.8
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/fixtures.js +2 -2
- package/dist/fixtures.js.map +1 -1
- package/dist/index.d.ts +45 -15
- package/dist/index.js +464 -97
- package/dist/index.js.map +1 -1
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types/fixtures.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/nav-tracker.d.ts.map +1 -1
- package/dist/types/otp.d.ts.map +1 -0
- package/dist/types/replay-utils.d.ts.map +1 -1
- package/package.json +26 -3
package/dist/fixtures.js
CHANGED
|
@@ -45,7 +45,7 @@ function createProboFixtures(config = {}) {
|
|
|
45
45
|
const defaultExtensionsPath = join(__dirname, '../loaded_extensions');
|
|
46
46
|
const extensionsDir = extensionsPath || defaultExtensionsPath;
|
|
47
47
|
return test$1.extend({
|
|
48
|
-
context: async ({}, use) => {
|
|
48
|
+
context: async ({ headless }, use) => {
|
|
49
49
|
// Extract extensions
|
|
50
50
|
const extensionDirs = [];
|
|
51
51
|
try {
|
|
@@ -59,7 +59,7 @@ function createProboFixtures(config = {}) {
|
|
|
59
59
|
// Launch Chromium with extensions
|
|
60
60
|
const userDataDir = mkdtempSync(join(tmpdir(), 'probo-user-data-'));
|
|
61
61
|
const context = await chromium.launchPersistentContext(userDataDir, {
|
|
62
|
-
headless
|
|
62
|
+
headless, // Extensions work better in non-headless mode
|
|
63
63
|
args: [
|
|
64
64
|
...extensionDirs.map(dir => `--load-extension=${dir}`),
|
|
65
65
|
'--disable-extensions-except=' + extensionDirs.join(','),
|
package/dist/fixtures.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.js","sources":["../src/fixtures.ts"],"sourcesContent":["import { test as base, chromium } from '@playwright/test';\nimport { readFileSync, mkdtempSync } from 'fs';\nimport { join, dirname } from 'path';\nimport { tmpdir } from 'os';\nimport
|
|
1
|
+
{"version":3,"file":"fixtures.js","sources":["../src/fixtures.ts"],"sourcesContent":["import { test as base, chromium } from '@playwright/test';\nimport { readFileSync, mkdtempSync } from 'fs';\nimport { join, dirname } from 'path';\nimport { tmpdir } from 'os';\nimport AdmZip from 'adm-zip';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Configuration options for Probo fixtures\n */\nexport interface ProboFixturesConfig {\n /** Whether to show browser console logs */\n showBrowserConsole?: boolean;\n /** Custom path to extensions directory */\n extensionsPath?: string;\n}\n\n/**\n * Extracts a CRX file to a temporary directory\n * Uses adm-zip with manual ZIP content detection\n */\nfunction extractCrxFile(crxPath: string): string {\n const crxBuffer = readFileSync(crxPath);\n \n // Find ZIP content by looking for ZIP magic number (PK)\n let zipStart = -1;\n for (let i = 0; i < crxBuffer.length - 4; i++) {\n if (crxBuffer[i] === 0x50 && crxBuffer[i + 1] === 0x4B) { // \"PK\"\n zipStart = i;\n break;\n }\n }\n \n if (zipStart === -1) {\n throw new Error('Could not find ZIP content in CRX file');\n }\n \n const zipBuffer = crxBuffer.subarray(zipStart);\n \n // Create temporary directory\n const tempDir = mkdtempSync(join(tmpdir(), 'probo-extension-'));\n \n // Extract ZIP content\n const zip = new AdmZip(zipBuffer);\n zip.extractAllTo(tempDir, true);\n \n return tempDir;\n}\n\n/**\n * Creates Probo fixtures that launch Chromium with extensions\n * \n * @param config Configuration options for the fixtures\n * @returns Extended test function with Probo fixtures\n */\nexport function createProboFixtures(config: ProboFixturesConfig = {}) {\n const { showBrowserConsole = false, extensionsPath } = config;\n \n // Default extensions path\n const defaultExtensionsPath = join(__dirname, '../loaded_extensions');\n const extensionsDir = extensionsPath || defaultExtensionsPath;\n\n return base.extend({\n context: async ({headless}, use) => {\n // Extract extensions\n const extensionDirs: string[] = [];\n \n try {\n const crxFile = join(extensionsDir, 'microsoft-single-sign-on.crx');\n const extractedDir = extractCrxFile(crxFile);\n extensionDirs.push(extractedDir);\n } catch (error) {\n console.warn('Could not load Microsoft SSO extension:', error);\n }\n \n // Launch Chromium with extensions\n const userDataDir = mkdtempSync(join(tmpdir(), 'probo-user-data-'));\n \n const context = await chromium.launchPersistentContext(userDataDir, {\n headless, // Extensions work better in non-headless mode\n args: [\n ...extensionDirs.map(dir => `--load-extension=${dir}`),\n '--disable-extensions-except=' + extensionDirs.join(','),\n '--disable-web-security', // Allow extensions to work properly\n '--disable-features=VizDisplayCompositor'\n ]\n });\n \n await use(context);\n \n // Cleanup\n await context.close();\n },\n \n page: async ({ context }, use) => {\n const page = await context.newPage();\n \n // Set up console logging if requested\n if (showBrowserConsole) {\n page.on('console', msg => console.log('Browser console:', msg.text()));\n }\n \n await use(page);\n await page.close();\n },\n });\n}\n\n/**\n * Default Probo fixtures with standard configuration\n * Launches Chromium with Microsoft SSO extension\n */\nexport const test = createProboFixtures();\n\n/**\n * Re-export expect from Playwright for convenience\n */\nexport { expect } from '@playwright/test';\n"],"names":["base"],"mappings":";;;;;;;;AAOA,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAYtC;;;AAGG;AACH,SAAS,cAAc,CAAC,OAAe,EAAA;AACrC,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;;AAGxC,IAAA,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC;AAClB,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC7C,QAAA,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;YACtD,QAAQ,GAAG,CAAC,CAAC;YACb,MAAM;SACP;KACF;AAED,IAA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AAE,EAAE,kBAAkB,CAAC,CAAC,CAAC;YAEpE,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,uBAAuB,CAAC,WAAW,EAAE;AAClE,gBAAA,QAAQ;AACR,gBAAA,IAAI,EAAE;oBACJ,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA,iBAAA,EAAoB,GAAG,CAAA,CAAE,CAAC;AACtD,oBAAA,8BAA8B,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC;AACxD,oBAAA,wBAAwB;oBACxB,yCAAyC;AAC1C,iBAAA;AACF,aAAA,CAAC,CAAC;AAEH,YAAA,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC;;AAGnB,YAAA,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;SACvB;QAED,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,KAAI;AAC/B,YAAA,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;;YAGrC,IAAI,kBAAkB,EAAE;gBACtB,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;aACxE;AAED,YAAA,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC;AAChB,YAAA,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;SACpB;AACF,KAAA,CAAC,CAAC;AACL,CAAC;AAED;;;AAGG;AACU,MAAA,IAAI,GAAG,mBAAmB;;;;"}
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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,11 @@ 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;
|
|
211
241
|
}
|
|
212
242
|
|
|
213
243
|
/**
|
|
@@ -222,7 +252,7 @@ interface ProboConfig {
|
|
|
222
252
|
logToFile?: boolean;
|
|
223
253
|
debugLevel?: ProboLogLevel;
|
|
224
254
|
aiModel?: AIModel;
|
|
225
|
-
timeoutConfig?: PlaywrightTimeoutConfig
|
|
255
|
+
timeoutConfig?: Partial<PlaywrightTimeoutConfig>;
|
|
226
256
|
}
|
|
227
257
|
interface RunStepOptions {
|
|
228
258
|
useCache: boolean;
|