playwright-mimic 0.1.0 → 0.1.1
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 +633 -446
- package/dist/agentic/agent.d.ts +106 -0
- package/dist/agentic/agent.d.ts.map +1 -0
- package/dist/agentic/agent.js +528 -0
- package/dist/agentic/agent.js.map +1 -0
- package/dist/agentic/index.d.ts +13 -0
- package/dist/agentic/index.d.ts.map +1 -0
- package/dist/agentic/index.js +12 -0
- package/dist/agentic/index.js.map +1 -0
- package/dist/agentic/planner.d.ts +41 -0
- package/dist/agentic/planner.d.ts.map +1 -0
- package/dist/agentic/planner.js +136 -0
- package/dist/agentic/planner.js.map +1 -0
- package/dist/agentic/react.d.ts +35 -0
- package/dist/agentic/react.d.ts.map +1 -0
- package/dist/agentic/react.js +170 -0
- package/dist/agentic/react.js.map +1 -0
- package/dist/agentic/recovery.d.ts +55 -0
- package/dist/agentic/recovery.d.ts.map +1 -0
- package/dist/agentic/recovery.js +200 -0
- package/dist/agentic/recovery.js.map +1 -0
- package/dist/agentic/reflection.d.ts +40 -0
- package/dist/agentic/reflection.d.ts.map +1 -0
- package/dist/agentic/reflection.js +142 -0
- package/dist/agentic/reflection.js.map +1 -0
- package/dist/agentic/types.d.ts +177 -0
- package/dist/agentic/types.d.ts.map +1 -0
- package/dist/agentic/types.js +8 -0
- package/dist/agentic/types.js.map +1 -0
- package/dist/agentic/wait.d.ts +50 -0
- package/dist/agentic/wait.d.ts.map +1 -0
- package/dist/agentic/wait.js +140 -0
- package/dist/agentic/wait.js.map +1 -0
- package/dist/agentic-mimic.d.ts +56 -0
- package/dist/agentic-mimic.d.ts.map +1 -0
- package/dist/agentic-mimic.js +98 -0
- package/dist/agentic-mimic.js.map +1 -0
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/mimic/actionType.d.ts +7 -0
- package/dist/mimic/actionType.d.ts.map +1 -0
- package/dist/mimic/actionType.js +44 -0
- package/dist/mimic/actionType.js.map +1 -0
- package/dist/mimic/annotations.d.ts +20 -0
- package/dist/mimic/annotations.d.ts.map +1 -0
- package/dist/mimic/annotations.js +30 -0
- package/dist/mimic/annotations.js.map +1 -0
- package/dist/mimic/cli.d.ts +15 -0
- package/dist/mimic/cli.d.ts.map +1 -0
- package/dist/mimic/cli.js +17 -0
- package/dist/mimic/cli.js.map +1 -0
- package/dist/mimic/click.d.ts +39 -0
- package/dist/mimic/click.d.ts.map +1 -0
- package/dist/mimic/click.js +233 -0
- package/dist/mimic/click.js.map +1 -0
- package/dist/mimic/forms.d.ts +47 -0
- package/dist/mimic/forms.d.ts.map +1 -0
- package/dist/mimic/forms.js +264 -0
- package/dist/mimic/forms.js.map +1 -0
- package/dist/mimic/navigation.d.ts +19 -0
- package/dist/mimic/navigation.d.ts.map +1 -0
- package/dist/mimic/navigation.js +117 -0
- package/dist/mimic/navigation.js.map +1 -0
- package/dist/mimic/replay.d.ts +21 -0
- package/dist/mimic/replay.d.ts.map +1 -0
- package/dist/mimic/replay.js +133 -0
- package/dist/mimic/replay.js.map +1 -0
- package/dist/mimic/schema/action.d.ts +315 -0
- package/dist/mimic/schema/action.d.ts.map +1 -0
- package/dist/mimic/schema/action.js +204 -0
- package/dist/mimic/schema/action.js.map +1 -0
- package/dist/mimic/selector.d.ts +139 -0
- package/dist/mimic/selector.d.ts.map +1 -0
- package/dist/mimic/selector.js +1103 -0
- package/dist/mimic/selector.js.map +1 -0
- package/dist/mimic/selectorDescriptor.d.ts +13 -0
- package/dist/mimic/selectorDescriptor.d.ts.map +1 -0
- package/dist/mimic/selectorDescriptor.js +9 -0
- package/dist/mimic/selectorDescriptor.js.map +1 -0
- package/dist/mimic/selectorSerialization.d.ts +30 -0
- package/dist/mimic/selectorSerialization.d.ts.map +1 -0
- package/dist/mimic/selectorSerialization.js +170 -0
- package/dist/mimic/selectorSerialization.js.map +1 -0
- package/dist/mimic/selectorTypes.d.ts +200 -0
- package/dist/mimic/selectorTypes.d.ts.map +1 -0
- package/dist/mimic/selectorTypes.js +2 -0
- package/dist/mimic/selectorTypes.js.map +1 -0
- package/dist/mimic/selectorUtils.d.ts +26 -0
- package/dist/mimic/selectorUtils.d.ts.map +1 -0
- package/dist/mimic/selectorUtils.js +144 -0
- package/dist/mimic/selectorUtils.js.map +1 -0
- package/dist/mimic/storage.d.ts +75 -0
- package/dist/mimic/storage.d.ts.map +1 -0
- package/dist/mimic/storage.js +197 -0
- package/dist/mimic/storage.js.map +1 -0
- package/dist/mimic/types.d.ts +63 -0
- package/dist/mimic/types.d.ts.map +1 -0
- package/dist/mimic/types.js +7 -0
- package/dist/mimic/types.js.map +1 -0
- package/dist/mimic.d.ts +28 -4
- package/dist/mimic.d.ts.map +1 -1
- package/dist/mimic.js +374 -32
- package/dist/mimic.js.map +1 -1
- package/dist/mimicry.d.ts +4 -4
- package/dist/mimicry.d.ts.map +1 -1
- package/dist/mimicry.js +22 -13
- package/dist/mimicry.js.map +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { generateText, Output } from 'ai';
|
|
2
|
+
import { zNavigationAction, } from './schema/action.js';
|
|
3
|
+
import { countTokens } from '../utils/token-counter.js';
|
|
4
|
+
import { addAnnotation } from './annotations.js';
|
|
5
|
+
export const getNavigationAction = async (_page, brain, action, testContext) => {
|
|
6
|
+
// Build context description for the prompt
|
|
7
|
+
const contextDescription = testContext ? `
|
|
8
|
+
**Test Context:**
|
|
9
|
+
- Current URL: ${testContext.currentState.url}
|
|
10
|
+
- Current Page Title: ${testContext.currentState.pageTitle}
|
|
11
|
+
- Step ${testContext.currentStepIndex + 1} of ${testContext.totalSteps}
|
|
12
|
+
${testContext.previousSteps.length > 0 ? `
|
|
13
|
+
**Previous Steps Executed:**
|
|
14
|
+
${testContext.previousSteps.map((prevStep, idx) => `${idx + 1}. Step ${prevStep.stepIndex + 1}: "${prevStep.stepText}" (${prevStep.actionKind}${prevStep.url ? ` → ${prevStep.url}` : ''})`).join('\n')}
|
|
15
|
+
` : ''}
|
|
16
|
+
` : '';
|
|
17
|
+
const res = await generateText({
|
|
18
|
+
model: brain,
|
|
19
|
+
maxRetries: 3,
|
|
20
|
+
prompt: `You are an expert in converting Gherkin test steps into structured browser automation action objects using Playwright.
|
|
21
|
+
|
|
22
|
+
Your task is to process a single Gherkin step and determine whether it represents a **navigation** action. this can be any of the following:
|
|
23
|
+
- navigate to a page (this requires a url, if no url is provided, go for an option below)
|
|
24
|
+
- closePage: close the current page
|
|
25
|
+
- goBack: go back to the previous page, or navigate back in the browser history
|
|
26
|
+
- goForward: go forward to the next page, or navigate forward in the browser history
|
|
27
|
+
- refresh: refresh the current page, or reload the page
|
|
28
|
+
|
|
29
|
+
${contextDescription}
|
|
30
|
+
**Input Gherkin step:** ${action}
|
|
31
|
+
|
|
32
|
+
**Instructions:**
|
|
33
|
+
1. Determine the navigation type and extract the URL if applicable
|
|
34
|
+
2. Provide a clear, human-readable description of what navigation is happening
|
|
35
|
+
- For navigate/openPage: "Navigate to [page name or URL]" (e.g., "Navigate to login page", "Navigate to https://example.com")
|
|
36
|
+
- Do not hallucinate the domain, if none are mentioned, just pass the uri (e.g., "/login")
|
|
37
|
+
- For goBack: "Go back to previous page in browser history" (the system will add the specific URL information)
|
|
38
|
+
- For goForward: "Go forward to next page in browser history" (the system will add the specific URL information)
|
|
39
|
+
- For refresh: "Refresh the current page" (the system will add the specific URL information)
|
|
40
|
+
- For closePage: "Close the current browser page/tab" (the system will add the specific URL information)
|
|
41
|
+
|
|
42
|
+
`,
|
|
43
|
+
output: Output.object({ schema: zNavigationAction, name: 'navigation' }),
|
|
44
|
+
});
|
|
45
|
+
await countTokens(res);
|
|
46
|
+
return res.output;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Execute a navigation action on the page with plain English annotation
|
|
50
|
+
*
|
|
51
|
+
* This function performs browser navigation actions (navigate, go back, refresh, etc.)
|
|
52
|
+
* and adds test annotations for better traceability and validation.
|
|
53
|
+
*
|
|
54
|
+
* @param page - Playwright Page object to perform navigation on
|
|
55
|
+
* @param navigationAction - Navigation action containing type, parameters, and description
|
|
56
|
+
* @param testInfo - Playwright TestInfo for adding annotations (optional)
|
|
57
|
+
* @param gherkinStep - The original Gherkin step for annotation type (optional)
|
|
58
|
+
* @returns Promise that resolves to the navigation action (for snapshot storage)
|
|
59
|
+
*/
|
|
60
|
+
export const executeNavigationAction = async (page, navigationAction, testInfo, gherkinStep) => {
|
|
61
|
+
// Use LLM-generated description or build a default one
|
|
62
|
+
const actionDescription = navigationAction.description || 'navigation action';
|
|
63
|
+
switch (navigationAction.type) {
|
|
64
|
+
case 'openPage':
|
|
65
|
+
case 'navigate':
|
|
66
|
+
addAnnotation(testInfo, gherkinStep, `→ ${actionDescription} and waiting for page to load completely`);
|
|
67
|
+
await page.goto(navigationAction.params.url, { waitUntil: 'networkidle' });
|
|
68
|
+
break;
|
|
69
|
+
case 'closePage':
|
|
70
|
+
// Only close page if explicitly requested - be very careful with this action
|
|
71
|
+
// Check if page is still open before closing
|
|
72
|
+
if (page.isClosed()) {
|
|
73
|
+
addAnnotation(testInfo, gherkinStep, `→ Page is already closed, cannot close again`);
|
|
74
|
+
return navigationAction;
|
|
75
|
+
}
|
|
76
|
+
// Capture current URL for better traceability
|
|
77
|
+
const currentUrlBeforeClose = page.url();
|
|
78
|
+
addAnnotation(testInfo, gherkinStep, `→ ${actionDescription} (closing page at ${currentUrlBeforeClose})`);
|
|
79
|
+
await page.close();
|
|
80
|
+
break;
|
|
81
|
+
case 'goBack':
|
|
82
|
+
// Capture current URL before going back for better traceability
|
|
83
|
+
const currentUrlBeforeBack = page.url();
|
|
84
|
+
await page.goBack();
|
|
85
|
+
try {
|
|
86
|
+
const urlAfterBack = page.url();
|
|
87
|
+
addAnnotation(testInfo, gherkinStep, `→ ${actionDescription} (from ${currentUrlBeforeBack} to ${urlAfterBack})`);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
addAnnotation(testInfo, gherkinStep, `→ ${actionDescription} (from ${currentUrlBeforeBack})`);
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case 'goForward':
|
|
94
|
+
// Capture current URL before going forward for better traceability
|
|
95
|
+
const currentUrlBeforeForward = page.url();
|
|
96
|
+
await page.goForward();
|
|
97
|
+
try {
|
|
98
|
+
const urlAfterForward = page.url();
|
|
99
|
+
addAnnotation(testInfo, gherkinStep, `→ ${actionDescription} (from ${currentUrlBeforeForward} to ${urlAfterForward})`);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
addAnnotation(testInfo, gherkinStep, `→ ${actionDescription} (from ${currentUrlBeforeForward})`);
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
case 'refresh':
|
|
106
|
+
// Capture current URL for better traceability
|
|
107
|
+
const currentUrlBeforeRefresh = page.url();
|
|
108
|
+
addAnnotation(testInfo, gherkinStep, `→ ${actionDescription} to reload all content (refreshing ${currentUrlBeforeRefresh})`);
|
|
109
|
+
await page.reload();
|
|
110
|
+
break;
|
|
111
|
+
default:
|
|
112
|
+
throw new Error(`Unknown navigation action type: ${navigationAction.type}`);
|
|
113
|
+
}
|
|
114
|
+
// Return the action for snapshot storage
|
|
115
|
+
return navigationAction;
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=navigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/mimic/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,EAAE,MAAM,IAAI,CAAA;AAG7D,OAAO,EACL,iBAAiB,GAElB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAC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CAAC,CAAC;YAChG,CAAC;YACD,MAAM;QACR,KAAK,WAAW;YACd,mEAAmE;YACnE,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC3C,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC;gBACH,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBACnC,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,iBAAiB,UAAU,uBAAuB,OAAO,eAAe,GAAG,CAAC,CAAC;YACzH,CAAC;YAAC,MAAM,CAAC;gBACP,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,iBAAiB,UAAU,uBAAuB,GAAG,CAAC,CAAC;YACnG,CAAC;YACD,MAAM;QACR,KAAK,SAAS;YACZ,8CAA8C;YAC9C,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC3C,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,iBAAiB,sCAAsC,uBAAuB,GAAG,CAAC,CAAC;YAC7H,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,mCAAmC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,yCAAyC;IACzC,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot Replay Module
|
|
3
|
+
*
|
|
4
|
+
* Replays test steps from a snapshot without using LLM calls.
|
|
5
|
+
* This provides fast, deterministic test execution for previously successful tests.
|
|
6
|
+
*/
|
|
7
|
+
import { Page, TestInfo } from '@playwright/test';
|
|
8
|
+
import type { Snapshot } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Replay a complete test from a snapshot
|
|
11
|
+
*
|
|
12
|
+
* Executes all steps in the snapshot without making LLM calls.
|
|
13
|
+
* This is much faster than normal execution since it skips AI analysis.
|
|
14
|
+
*
|
|
15
|
+
* @param page - Playwright Page object
|
|
16
|
+
* @param snapshot - Snapshot containing steps to replay
|
|
17
|
+
* @param testInfo - Playwright TestInfo for annotations (optional)
|
|
18
|
+
* @returns Promise that resolves when all steps are replayed
|
|
19
|
+
*/
|
|
20
|
+
export declare function replayFromSnapshot(page: Page, snapshot: Snapshot, testInfo?: TestInfo): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/mimic/replay.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAQ,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAUzD;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot Replay Module
|
|
3
|
+
*
|
|
4
|
+
* Replays test steps from a snapshot without using LLM calls.
|
|
5
|
+
* This provides fast, deterministic test execution for previously successful tests.
|
|
6
|
+
*/
|
|
7
|
+
import { test } from '@playwright/test';
|
|
8
|
+
import { executeNavigationAction } from './navigation.js';
|
|
9
|
+
import { executeClickAction } from './click.js';
|
|
10
|
+
import { executeFormAction } from './forms.js';
|
|
11
|
+
import { buildSelectorForTarget } from './selector.js';
|
|
12
|
+
/**
|
|
13
|
+
* Replay a complete test from a snapshot
|
|
14
|
+
*
|
|
15
|
+
* Executes all steps in the snapshot without making LLM calls.
|
|
16
|
+
* This is much faster than normal execution since it skips AI analysis.
|
|
17
|
+
*
|
|
18
|
+
* @param page - Playwright Page object
|
|
19
|
+
* @param snapshot - Snapshot containing steps to replay
|
|
20
|
+
* @param testInfo - Playwright TestInfo for annotations (optional)
|
|
21
|
+
* @returns Promise that resolves when all steps are replayed
|
|
22
|
+
*/
|
|
23
|
+
export async function replayFromSnapshot(page, snapshot, testInfo) {
|
|
24
|
+
// Replay each step in order
|
|
25
|
+
for (const step of snapshot.steps) {
|
|
26
|
+
await test.step(step.stepText, async () => {
|
|
27
|
+
switch (step.actionKind) {
|
|
28
|
+
case 'navigation':
|
|
29
|
+
await replayNavigationStep(page, step, testInfo);
|
|
30
|
+
break;
|
|
31
|
+
case 'click':
|
|
32
|
+
await replayClickStep(page, step, testInfo);
|
|
33
|
+
break;
|
|
34
|
+
case 'form update':
|
|
35
|
+
await replayFormStep(page, step, testInfo);
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
throw new Error(`Unknown action kind in snapshot: ${step.actionKind}`);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Replay a navigation step from snapshot
|
|
45
|
+
*
|
|
46
|
+
* @param page - Playwright Page object
|
|
47
|
+
* @param step - Snapshot step containing navigation action
|
|
48
|
+
* @param testInfo - Playwright TestInfo for annotations (optional)
|
|
49
|
+
* @returns Promise that resolves when navigation is complete
|
|
50
|
+
*/
|
|
51
|
+
async function replayNavigationStep(page, step, testInfo) {
|
|
52
|
+
const actionDetails = step.actionDetails;
|
|
53
|
+
await executeNavigationAction(page, actionDetails, testInfo, step.stepText);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Replay a click step from snapshot
|
|
57
|
+
*
|
|
58
|
+
* Reconstructs the locator from stored target element information.
|
|
59
|
+
*
|
|
60
|
+
* @param page - Playwright Page object
|
|
61
|
+
* @param step - Snapshot step containing click action
|
|
62
|
+
* @param testInfo - Playwright TestInfo for annotations (optional)
|
|
63
|
+
* @returns Promise that resolves when click is complete
|
|
64
|
+
*/
|
|
65
|
+
async function replayClickStep(page, step, testInfo) {
|
|
66
|
+
const actionDetails = step.actionDetails;
|
|
67
|
+
// Reconstruct the target element from snapshot
|
|
68
|
+
if (!step.targetElement) {
|
|
69
|
+
throw new Error(`Snapshot step ${step.stepIndex} (click) is missing targetElement`);
|
|
70
|
+
}
|
|
71
|
+
// If we have a stored selector, try to use it directly
|
|
72
|
+
let element;
|
|
73
|
+
if (step.targetElement.selector) {
|
|
74
|
+
try {
|
|
75
|
+
element = page.locator(step.targetElement.selector);
|
|
76
|
+
// Verify the element exists
|
|
77
|
+
await element.waitFor({ timeout: 5000 });
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
// Selector might be stale, fall back to rebuilding from TargetInfo
|
|
81
|
+
console.warn(`Stored selector failed for step ${step.stepIndex}, rebuilding from TargetInfo`);
|
|
82
|
+
element = await buildSelectorForTarget(page, step.targetElement);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Rebuild selector from TargetInfo
|
|
87
|
+
element = await buildSelectorForTarget(page, step.targetElement);
|
|
88
|
+
}
|
|
89
|
+
// Find the selected candidate from the click action result
|
|
90
|
+
// The first candidate should be the one we used originally
|
|
91
|
+
const selectedCandidate = actionDetails.candidates[0];
|
|
92
|
+
if (!selectedCandidate) {
|
|
93
|
+
throw new Error(`Snapshot step ${step.stepIndex} (click) has no candidates in actionDetails`);
|
|
94
|
+
}
|
|
95
|
+
await executeClickAction(element, actionDetails, selectedCandidate, testInfo, step.stepText);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Replay a form step from snapshot
|
|
99
|
+
*
|
|
100
|
+
* Reconstructs the form element locator from stored target element information.
|
|
101
|
+
*
|
|
102
|
+
* @param page - Playwright Page object
|
|
103
|
+
* @param step - Snapshot step containing form action
|
|
104
|
+
* @param testInfo - Playwright TestInfo for annotations (optional)
|
|
105
|
+
* @returns Promise that resolves when form action is complete
|
|
106
|
+
*/
|
|
107
|
+
async function replayFormStep(page, step, testInfo) {
|
|
108
|
+
const actionDetails = step.actionDetails;
|
|
109
|
+
// Reconstruct the target element from snapshot
|
|
110
|
+
if (!step.targetElement) {
|
|
111
|
+
throw new Error(`Snapshot step ${step.stepIndex} (form) is missing targetElement`);
|
|
112
|
+
}
|
|
113
|
+
// If we have a stored selector, try to use it directly
|
|
114
|
+
let element;
|
|
115
|
+
if (step.targetElement.selector) {
|
|
116
|
+
try {
|
|
117
|
+
element = page.locator(step.targetElement.selector);
|
|
118
|
+
// Verify the element exists
|
|
119
|
+
await element.waitFor({ timeout: 5000 });
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
// Selector might be stale, fall back to rebuilding from TargetInfo
|
|
123
|
+
console.warn(`Stored selector failed for step ${step.stepIndex}, rebuilding from TargetInfo`);
|
|
124
|
+
element = await buildSelectorForTarget(page, step.targetElement);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Rebuild selector from TargetInfo
|
|
129
|
+
element = await buildSelectorForTarget(page, step.targetElement);
|
|
130
|
+
}
|
|
131
|
+
await executeFormAction(page, actionDetails, element, testInfo, step.stepText);
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../src/mimic/replay.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAkB,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAMvD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAA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AAC;IAED,uDAAuD;IACvD,IAAI,OAAO,CAAC;IACZ,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YACpD,4BAA4B;YAC5B,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,mEAAmE;YACnE,OAAO,CAAC,IAAI,CAAC,mCAAmC,IAAI,CAAC,SAAS,8BAA8B,CAAC,CAAC;YAC9F,OAAO,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,aAA2B,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;SAAM,CAAC;QACN,mCAAmC;QACnC,OAAO,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,aAA2B,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,iBAAiB,CACrB,IAAI,EACJ,aAAa,EACb,OAAO,EACP,QAAQ,EACR,IAAI,CAAC,QAAQ,CACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Shared: identifiers and primitive helpers
|
|
4
|
+
*/
|
|
5
|
+
export declare const zPoint: z.ZodObject<{
|
|
6
|
+
x: z.ZodNumber;
|
|
7
|
+
y: z.ZodNumber;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const zMouseButton: z.ZodEnum<{
|
|
10
|
+
left: "left";
|
|
11
|
+
middle: "middle";
|
|
12
|
+
right: "right";
|
|
13
|
+
}>;
|
|
14
|
+
export declare const zModifierKeys: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
15
|
+
Alt: "Alt";
|
|
16
|
+
Control: "Control";
|
|
17
|
+
Meta: "Meta";
|
|
18
|
+
Shift: "Shift";
|
|
19
|
+
}>>>;
|
|
20
|
+
export declare const zFrameDescription: z.ZodObject<{
|
|
21
|
+
pageGuid: z.ZodString;
|
|
22
|
+
pageAlias: z.ZodString;
|
|
23
|
+
framePath: z.ZodArray<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
/**
|
|
26
|
+
* ACTION INTENT (PASS 1): coarse category only
|
|
27
|
+
* Keep this small so an LLM can commit early with high accuracy.
|
|
28
|
+
*/
|
|
29
|
+
export declare const zActionKind: z.ZodEnum<{
|
|
30
|
+
navigation: "navigation";
|
|
31
|
+
click: "click";
|
|
32
|
+
assertion: "assertion";
|
|
33
|
+
other: "other";
|
|
34
|
+
"form update": "form update";
|
|
35
|
+
}>;
|
|
36
|
+
export declare const zGeneralActionPlan: z.ZodObject<{
|
|
37
|
+
kind: z.ZodEnum<{
|
|
38
|
+
navigation: "navigation";
|
|
39
|
+
click: "click";
|
|
40
|
+
assertion: "assertion";
|
|
41
|
+
other: "other";
|
|
42
|
+
"form update": "form update";
|
|
43
|
+
}>;
|
|
44
|
+
description: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
/**
|
|
47
|
+
* ACTION SUBTYPE (PASS 2): constrained sub-choices within the category? maybe add as object with values or special
|
|
48
|
+
*/
|
|
49
|
+
export declare const zMouseType: z.ZodEnum<{
|
|
50
|
+
click: "click";
|
|
51
|
+
doubleClick: "doubleClick";
|
|
52
|
+
hover: "hover";
|
|
53
|
+
}>;
|
|
54
|
+
export declare const zFormUpdateTypes: z.ZodEnum<{
|
|
55
|
+
type: "type";
|
|
56
|
+
select: "select";
|
|
57
|
+
fill: "fill";
|
|
58
|
+
check: "check";
|
|
59
|
+
press: "press";
|
|
60
|
+
uncheck: "uncheck";
|
|
61
|
+
setInputFiles: "setInputFiles";
|
|
62
|
+
clear: "clear";
|
|
63
|
+
}>;
|
|
64
|
+
export declare const zNavigationType: z.ZodEnum<{
|
|
65
|
+
openPage: "openPage";
|
|
66
|
+
navigate: "navigate";
|
|
67
|
+
closePage: "closePage";
|
|
68
|
+
goBack: "goBack";
|
|
69
|
+
goForward: "goForward";
|
|
70
|
+
refresh: "refresh";
|
|
71
|
+
openInNewTab: "openInNewTab";
|
|
72
|
+
}>;
|
|
73
|
+
export declare const zAssertionType: z.ZodEnum<{
|
|
74
|
+
"text visible": "text visible";
|
|
75
|
+
"value visible": "value visible";
|
|
76
|
+
"checked visible": "checked visible";
|
|
77
|
+
"aria snapshot visible": "aria snapshot visible";
|
|
78
|
+
"screenshot of element": "screenshot of element";
|
|
79
|
+
}>;
|
|
80
|
+
export declare const zMouseAction: z.ZodObject<{
|
|
81
|
+
type: z.ZodEnum<{
|
|
82
|
+
click: "click";
|
|
83
|
+
doubleClick: "doubleClick";
|
|
84
|
+
hover: "hover";
|
|
85
|
+
}>;
|
|
86
|
+
params: z.ZodObject<{
|
|
87
|
+
button: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
88
|
+
left: "left";
|
|
89
|
+
middle: "middle";
|
|
90
|
+
right: "right";
|
|
91
|
+
}>>>>;
|
|
92
|
+
position: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
93
|
+
x: z.ZodNumber;
|
|
94
|
+
y: z.ZodNumber;
|
|
95
|
+
}, z.core.$strip>>>;
|
|
96
|
+
modifiers: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
97
|
+
Alt: "Alt";
|
|
98
|
+
Control: "Control";
|
|
99
|
+
Meta: "Meta";
|
|
100
|
+
Shift: "Shift";
|
|
101
|
+
}>>>>>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
export declare const zFormUpdateAction: z.ZodObject<{
|
|
105
|
+
type: z.ZodEnum<{
|
|
106
|
+
type: "type";
|
|
107
|
+
select: "select";
|
|
108
|
+
fill: "fill";
|
|
109
|
+
check: "check";
|
|
110
|
+
press: "press";
|
|
111
|
+
uncheck: "uncheck";
|
|
112
|
+
setInputFiles: "setInputFiles";
|
|
113
|
+
clear: "clear";
|
|
114
|
+
}>;
|
|
115
|
+
params: z.ZodObject<{
|
|
116
|
+
value: z.ZodString;
|
|
117
|
+
modifiers: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
118
|
+
Alt: "Alt";
|
|
119
|
+
Control: "Control";
|
|
120
|
+
Meta: "Meta";
|
|
121
|
+
Shift: "Shift";
|
|
122
|
+
}>>>>>;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
}, z.core.$strip>;
|
|
125
|
+
export declare const zNavigationAction: z.ZodObject<{
|
|
126
|
+
type: z.ZodEnum<{
|
|
127
|
+
openPage: "openPage";
|
|
128
|
+
navigate: "navigate";
|
|
129
|
+
closePage: "closePage";
|
|
130
|
+
goBack: "goBack";
|
|
131
|
+
goForward: "goForward";
|
|
132
|
+
refresh: "refresh";
|
|
133
|
+
openInNewTab: "openInNewTab";
|
|
134
|
+
}>;
|
|
135
|
+
params: z.ZodObject<{
|
|
136
|
+
url: z.ZodNullable<z.ZodString>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
description: z.ZodString;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
export type NavigationAction = z.infer<typeof zNavigationAction>;
|
|
141
|
+
/**
|
|
142
|
+
* Click action result schema
|
|
143
|
+
* Contains top candidate elements matched against a Gherkin step
|
|
144
|
+
*/
|
|
145
|
+
export declare const zClickActionResult: z.ZodObject<{
|
|
146
|
+
candidates: z.ZodArray<z.ZodObject<{
|
|
147
|
+
index: z.ZodNumber;
|
|
148
|
+
tag: z.ZodString;
|
|
149
|
+
text: z.ZodString;
|
|
150
|
+
id: z.ZodNullable<z.ZodString>;
|
|
151
|
+
role: z.ZodNullable<z.ZodString>;
|
|
152
|
+
label: z.ZodNullable<z.ZodString>;
|
|
153
|
+
ariaLabel: z.ZodNullable<z.ZodString>;
|
|
154
|
+
confidence: z.ZodNullable<z.ZodNumber>;
|
|
155
|
+
description: z.ZodString;
|
|
156
|
+
}, z.core.$strip>>;
|
|
157
|
+
clickType: z.ZodEnum<{
|
|
158
|
+
left: "left";
|
|
159
|
+
middle: "middle";
|
|
160
|
+
right: "right";
|
|
161
|
+
hover: "hover";
|
|
162
|
+
double: "double";
|
|
163
|
+
}>;
|
|
164
|
+
reasoning: z.ZodString;
|
|
165
|
+
}, z.core.$strip>;
|
|
166
|
+
export type ClickActionResult = z.infer<typeof zClickActionResult>;
|
|
167
|
+
export declare const zAssertionAction: z.ZodObject<{
|
|
168
|
+
type: z.ZodEnum<{
|
|
169
|
+
"text visible": "text visible";
|
|
170
|
+
"value visible": "value visible";
|
|
171
|
+
"checked visible": "checked visible";
|
|
172
|
+
"aria snapshot visible": "aria snapshot visible";
|
|
173
|
+
"screenshot of element": "screenshot of element";
|
|
174
|
+
}>;
|
|
175
|
+
params: z.ZodObject<{
|
|
176
|
+
expected: z.ZodString;
|
|
177
|
+
}, z.core.$strip>;
|
|
178
|
+
}, z.core.$strip>;
|
|
179
|
+
export declare const zOtherAction: z.ZodObject<{
|
|
180
|
+
type: z.ZodLiteral<"custom">;
|
|
181
|
+
params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
182
|
+
}, z.core.$strip>;
|
|
183
|
+
/**
|
|
184
|
+
* ACTION SUBTYPE (PASS 2): Union of all subtype schemas with kind
|
|
185
|
+
* This allows progressive refinement: first get kind, then get specific subtype.
|
|
186
|
+
*/
|
|
187
|
+
export declare const zActionPass2: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
188
|
+
kind: z.ZodLiteral<"mouse">;
|
|
189
|
+
type: z.ZodEnum<{
|
|
190
|
+
click: "click";
|
|
191
|
+
doubleClick: "doubleClick";
|
|
192
|
+
hover: "hover";
|
|
193
|
+
}>;
|
|
194
|
+
params: z.ZodObject<{
|
|
195
|
+
button: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
196
|
+
left: "left";
|
|
197
|
+
middle: "middle";
|
|
198
|
+
right: "right";
|
|
199
|
+
}>>>>;
|
|
200
|
+
position: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
201
|
+
x: z.ZodNumber;
|
|
202
|
+
y: z.ZodNumber;
|
|
203
|
+
}, z.core.$strip>>>;
|
|
204
|
+
modifiers: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
205
|
+
Alt: "Alt";
|
|
206
|
+
Control: "Control";
|
|
207
|
+
Meta: "Meta";
|
|
208
|
+
Shift: "Shift";
|
|
209
|
+
}>>>>>;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
212
|
+
kind: z.ZodLiteral<"form update">;
|
|
213
|
+
type: z.ZodEnum<{
|
|
214
|
+
type: "type";
|
|
215
|
+
select: "select";
|
|
216
|
+
fill: "fill";
|
|
217
|
+
check: "check";
|
|
218
|
+
press: "press";
|
|
219
|
+
uncheck: "uncheck";
|
|
220
|
+
setInputFiles: "setInputFiles";
|
|
221
|
+
clear: "clear";
|
|
222
|
+
}>;
|
|
223
|
+
params: z.ZodObject<{
|
|
224
|
+
value: z.ZodString;
|
|
225
|
+
modifiers: z.ZodOptional<z.ZodNullable<z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
226
|
+
Alt: "Alt";
|
|
227
|
+
Control: "Control";
|
|
228
|
+
Meta: "Meta";
|
|
229
|
+
Shift: "Shift";
|
|
230
|
+
}>>>>>;
|
|
231
|
+
}, z.core.$strip>;
|
|
232
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
233
|
+
kind: z.ZodLiteral<"navigation">;
|
|
234
|
+
type: z.ZodEnum<{
|
|
235
|
+
openPage: "openPage";
|
|
236
|
+
navigate: "navigate";
|
|
237
|
+
closePage: "closePage";
|
|
238
|
+
goBack: "goBack";
|
|
239
|
+
goForward: "goForward";
|
|
240
|
+
refresh: "refresh";
|
|
241
|
+
openInNewTab: "openInNewTab";
|
|
242
|
+
}>;
|
|
243
|
+
params: z.ZodObject<{
|
|
244
|
+
url: z.ZodNullable<z.ZodString>;
|
|
245
|
+
}, z.core.$strip>;
|
|
246
|
+
description: z.ZodString;
|
|
247
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
248
|
+
kind: z.ZodLiteral<"assertion">;
|
|
249
|
+
type: z.ZodEnum<{
|
|
250
|
+
"text visible": "text visible";
|
|
251
|
+
"value visible": "value visible";
|
|
252
|
+
"checked visible": "checked visible";
|
|
253
|
+
"aria snapshot visible": "aria snapshot visible";
|
|
254
|
+
"screenshot of element": "screenshot of element";
|
|
255
|
+
}>;
|
|
256
|
+
params: z.ZodObject<{
|
|
257
|
+
expected: z.ZodString;
|
|
258
|
+
}, z.core.$strip>;
|
|
259
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
260
|
+
kind: z.ZodLiteral<"other">;
|
|
261
|
+
type: z.ZodLiteral<"custom">;
|
|
262
|
+
params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
263
|
+
}, z.core.$strip>], "kind">;
|
|
264
|
+
/**
|
|
265
|
+
* ACTION DETAILS (PASS 3): parameters, selector link, and signals
|
|
266
|
+
* Each subtype has a focused schema to minimize ambiguity.
|
|
267
|
+
*/
|
|
268
|
+
export declare const zMouseParams: z.ZodObject<{
|
|
269
|
+
button: z.ZodDefault<z.ZodEnum<{
|
|
270
|
+
left: "left";
|
|
271
|
+
middle: "middle";
|
|
272
|
+
right: "right";
|
|
273
|
+
}>>;
|
|
274
|
+
clickCount: z.ZodDefault<z.ZodNumber>;
|
|
275
|
+
position: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
276
|
+
x: z.ZodNumber;
|
|
277
|
+
y: z.ZodNumber;
|
|
278
|
+
}, z.core.$strip>>>;
|
|
279
|
+
modifiers: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
280
|
+
Alt: "Alt";
|
|
281
|
+
Control: "Control";
|
|
282
|
+
Meta: "Meta";
|
|
283
|
+
Shift: "Shift";
|
|
284
|
+
}>>>;
|
|
285
|
+
}, z.core.$strip>;
|
|
286
|
+
export declare const zKeyboardPressParams: z.ZodObject<{
|
|
287
|
+
key: z.ZodString;
|
|
288
|
+
modifiers: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
289
|
+
Alt: "Alt";
|
|
290
|
+
Control: "Control";
|
|
291
|
+
Meta: "Meta";
|
|
292
|
+
Shift: "Shift";
|
|
293
|
+
}>>>;
|
|
294
|
+
}, z.core.$strip>;
|
|
295
|
+
export declare const zKeyboardTypeParams: z.ZodObject<{
|
|
296
|
+
text: z.ZodString;
|
|
297
|
+
delayMs: z.ZodDefault<z.ZodNumber>;
|
|
298
|
+
}, z.core.$strip>;
|
|
299
|
+
export declare const zKeyboardFillParams: z.ZodObject<{
|
|
300
|
+
value: z.ZodString;
|
|
301
|
+
}, z.core.$strip>;
|
|
302
|
+
export declare const zOpenPageParams: z.ZodObject<{
|
|
303
|
+
url: z.ZodString;
|
|
304
|
+
}, z.core.$strip>;
|
|
305
|
+
export declare const zNavigateParams: z.ZodObject<{
|
|
306
|
+
url: z.ZodString;
|
|
307
|
+
}, z.core.$strip>;
|
|
308
|
+
export declare const zClosePageParams: z.ZodObject<{
|
|
309
|
+
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
310
|
+
}, z.core.$strip>;
|
|
311
|
+
/**
|
|
312
|
+
* Type exports for convenience
|
|
313
|
+
*/
|
|
314
|
+
export type Point = z.infer<typeof zPoint>;
|
|
315
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../src/mimic/schema/action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,MAAM;;;iBAGjB,CAAC;AAE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