testchimp-runner-core 0.0.40 → 0.0.41
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/execution-service.d.ts.map +1 -1
- package/dist/execution-service.js +1 -3
- package/dist/execution-service.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/orchestrator/decision-parser.d.ts.map +1 -1
- package/dist/orchestrator/decision-parser.js +16 -0
- package/dist/orchestrator/decision-parser.js.map +1 -1
- package/dist/orchestrator/index.d.ts +3 -1
- package/dist/orchestrator/index.d.ts.map +1 -1
- package/dist/orchestrator/index.js +8 -1
- package/dist/orchestrator/index.js.map +1 -1
- package/dist/orchestrator/orchestrator-agent.d.ts +10 -4
- package/dist/orchestrator/orchestrator-agent.d.ts.map +1 -1
- package/dist/orchestrator/orchestrator-agent.js +347 -93
- package/dist/orchestrator/orchestrator-agent.js.map +1 -1
- package/dist/orchestrator/orchestrator-prompts.d.ts.map +1 -1
- package/dist/orchestrator/orchestrator-prompts.js +355 -415
- package/dist/orchestrator/orchestrator-prompts.js.map +1 -1
- package/dist/orchestrator/page-loading-utils.d.ts +15 -0
- package/dist/orchestrator/page-loading-utils.d.ts.map +1 -0
- package/dist/orchestrator/page-loading-utils.js +115 -0
- package/dist/orchestrator/page-loading-utils.js.map +1 -0
- package/dist/orchestrator/page-som-handler.d.ts +2 -1
- package/dist/orchestrator/page-som-handler.d.ts.map +1 -1
- package/dist/orchestrator/page-som-handler.js +250 -33
- package/dist/orchestrator/page-som-handler.js.map +1 -1
- package/dist/orchestrator/site-learnings-utils.d.ts +31 -0
- package/dist/orchestrator/site-learnings-utils.d.ts.map +1 -0
- package/dist/orchestrator/site-learnings-utils.js +175 -0
- package/dist/orchestrator/site-learnings-utils.js.map +1 -0
- package/dist/orchestrator/som-types.d.ts +2 -0
- package/dist/orchestrator/som-types.d.ts.map +1 -1
- package/dist/orchestrator/som-types.js.map +1 -1
- package/dist/orchestrator/tools/take-screenshot.d.ts.map +1 -1
- package/dist/orchestrator/tools/take-screenshot.js +10 -1
- package/dist/orchestrator/tools/take-screenshot.js.map +1 -1
- package/dist/orchestrator/types.d.ts +54 -9
- package/dist/orchestrator/types.d.ts.map +1 -1
- package/dist/orchestrator/types.js.map +1 -1
- package/dist/progress-reporter.d.ts +23 -2
- package/dist/progress-reporter.d.ts.map +1 -1
- package/dist/progress-reporter.js.map +1 -1
- package/dist/scenario-service.d.ts +3 -3
- package/dist/scenario-service.d.ts.map +1 -1
- package/dist/scenario-service.js +6 -5
- package/dist/scenario-service.js.map +1 -1
- package/dist/scenario-worker-class.d.ts +7 -3
- package/dist/scenario-worker-class.d.ts.map +1 -1
- package/dist/scenario-worker-class.js +62 -9
- package/dist/scenario-worker-class.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/testing/agent-tester.d.ts +0 -35
- package/dist/testing/agent-tester.d.ts.map +0 -1
- package/dist/testing/agent-tester.js +0 -84
- package/dist/testing/agent-tester.js.map +0 -1
- package/dist/testing/ref-translator-tester.d.ts +0 -44
- package/dist/testing/ref-translator-tester.d.ts.map +0 -1
- package/dist/testing/ref-translator-tester.js +0 -104
- package/dist/testing/ref-translator-tester.js.map +0 -1
- package/dist/utils/hierarchical-selector.d.ts +0 -47
- package/dist/utils/hierarchical-selector.d.ts.map +0 -1
- package/dist/utils/hierarchical-selector.js +0 -212
- package/dist/utils/hierarchical-selector.js.map +0 -1
- package/dist/utils/ref-attacher.d.ts +0 -21
- package/dist/utils/ref-attacher.d.ts.map +0 -1
- package/dist/utils/ref-attacher.js +0 -149
- package/dist/utils/ref-attacher.js.map +0 -1
- package/dist/utils/ref-translator.d.ts +0 -49
- package/dist/utils/ref-translator.d.ts.map +0 -1
- package/dist/utils/ref-translator.js +0 -276
- package/dist/utils/ref-translator.js.map +0 -1
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hierarchical Selector Generator
|
|
4
|
-
* Generates Playwright selectors using ARIA tree hierarchy for uniqueness
|
|
5
|
-
* Mimics Playwright's own selector generation strategy
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.HierarchicalSelectorGenerator = void 0;
|
|
9
|
-
class HierarchicalSelectorGenerator {
|
|
10
|
-
constructor(logger) {
|
|
11
|
-
this.logger = logger;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Generate Playwright selectors for a ref using ARIA tree hierarchy
|
|
15
|
-
* Returns selectors in priority order, considering parent context for uniqueness
|
|
16
|
-
*/
|
|
17
|
-
generateSelectorsForRef(ref, refMap, ariaTree) {
|
|
18
|
-
const element = refMap.get(ref);
|
|
19
|
-
if (!element) {
|
|
20
|
-
this.logger?.(`[HierarchicalSelector] Ref '${ref}' not found in refMap`, 'warn');
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
// Get ARIA tree path to understand hierarchy
|
|
24
|
-
const path = this.getAriaTreePath(ariaTree, ref);
|
|
25
|
-
const selectors = [];
|
|
26
|
-
// Strategy 1: BEST - Unique attribute (name, id, data-testid)
|
|
27
|
-
selectors.push(...this.generateUniqueAttributeSelectors(element));
|
|
28
|
-
// Strategy 2: GOOD - Parent-scoped semantic selectors
|
|
29
|
-
if (path) {
|
|
30
|
-
selectors.push(...this.generateParentScopedSelectors(element, path));
|
|
31
|
-
}
|
|
32
|
-
// Strategy 3: FALLBACK - nth-match based on sibling position
|
|
33
|
-
if (path) {
|
|
34
|
-
selectors.push(...this.generateNthMatchSelectors(element, path, ref));
|
|
35
|
-
}
|
|
36
|
-
// Strategy 4: LAST RESORT - Generic selectors with first()
|
|
37
|
-
selectors.push(...this.generateGenericFallbacks(element));
|
|
38
|
-
return selectors;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Strategy 1: Unique attributes (most reliable)
|
|
42
|
-
*/
|
|
43
|
-
generateUniqueAttributeSelectors(element) {
|
|
44
|
-
const selectors = [];
|
|
45
|
-
const { tag, name, id, ariaLabel, placeholder, type } = element;
|
|
46
|
-
// name attribute (best for forms)
|
|
47
|
-
if (name && (tag === 'input' || tag === 'textarea' || tag === 'select')) {
|
|
48
|
-
selectors.push(`${tag}[name="${name}"]`);
|
|
49
|
-
}
|
|
50
|
-
// data-testid
|
|
51
|
-
if (element.dataTestId) {
|
|
52
|
-
selectors.push(`[data-testid="${element.dataTestId}"]`);
|
|
53
|
-
}
|
|
54
|
-
// ID (only if stable - avoid auto-generated)
|
|
55
|
-
if (id && !id.match(/^(rc_|:r[0-9]+:|__|«)/)) {
|
|
56
|
-
selectors.push(`#${id}`);
|
|
57
|
-
}
|
|
58
|
-
// aria-label (semantic)
|
|
59
|
-
if (ariaLabel && ariaLabel.length > 0 && ariaLabel.length < 50) {
|
|
60
|
-
selectors.push(`[aria-label="${this.escape(ariaLabel)}"]`);
|
|
61
|
-
}
|
|
62
|
-
// placeholder
|
|
63
|
-
if (placeholder && placeholder.length > 0) {
|
|
64
|
-
selectors.push(`[placeholder="${this.escape(placeholder)}"]`);
|
|
65
|
-
}
|
|
66
|
-
return selectors;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Strategy 2: Parent-scoped selectors (uses hierarchy for uniqueness)
|
|
70
|
-
*/
|
|
71
|
-
generateParentScopedSelectors(element, path) {
|
|
72
|
-
const selectors = [];
|
|
73
|
-
const { role, text, tag } = element;
|
|
74
|
-
const nodes = path.nodes;
|
|
75
|
-
if (nodes.length < 2)
|
|
76
|
-
return selectors; // Need at least parent + target
|
|
77
|
-
// Get parent and grandparent for context
|
|
78
|
-
const parent = nodes[nodes.length - 2];
|
|
79
|
-
const grandparent = nodes.length >= 3 ? nodes[nodes.length - 3] : null;
|
|
80
|
-
// Parent has text content - use it for scoping
|
|
81
|
-
if (parent.name && parent.name.length > 0 && parent.name.length < 50) {
|
|
82
|
-
// Approach 1: Scope by parent text, then find by role
|
|
83
|
-
if (role) {
|
|
84
|
-
selectors.push(`text=${parent.name} >> [role="${role}"]`);
|
|
85
|
-
}
|
|
86
|
-
// Approach 2: Scope by parent text, then find by tag
|
|
87
|
-
if (tag) {
|
|
88
|
-
selectors.push(`text=${parent.name} >> ${tag}`);
|
|
89
|
-
}
|
|
90
|
-
// Approach 3: Use getByText parent chaining (Playwright style)
|
|
91
|
-
if (text && text.length > 0) {
|
|
92
|
-
selectors.push(`text=${parent.name} >> text=${text}`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// Grandparent scoping (for nested structures)
|
|
96
|
-
if (grandparent && grandparent.name && grandparent.name.length > 0) {
|
|
97
|
-
if (role) {
|
|
98
|
-
selectors.push(`text=${grandparent.name} >> [role="${role}"]`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// Text content with role (if element has visible text)
|
|
102
|
-
if (text && text.length > 0 && text.length < 30 && role) {
|
|
103
|
-
selectors.push(`[role="${role}"][aria-label*="${this.escape(text)}"]`);
|
|
104
|
-
}
|
|
105
|
-
return selectors;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Strategy 3: nth-match based on sibling position in ARIA tree
|
|
109
|
-
*/
|
|
110
|
-
generateNthMatchSelectors(element, path, ref) {
|
|
111
|
-
const selectors = [];
|
|
112
|
-
const { role, tag, text } = element;
|
|
113
|
-
const nodes = path.nodes;
|
|
114
|
-
if (nodes.length < 2)
|
|
115
|
-
return selectors;
|
|
116
|
-
const parent = nodes[nodes.length - 2];
|
|
117
|
-
// Find position among siblings with same role
|
|
118
|
-
const siblingsWithSameRole = (parent.children || []).filter((child) => child.role === role);
|
|
119
|
-
const position = siblingsWithSameRole.findIndex((child) => child.ref === ref);
|
|
120
|
-
if (position >= 0) {
|
|
121
|
-
// nth-match by role
|
|
122
|
-
if (role) {
|
|
123
|
-
selectors.push(`[role="${role}"] >> nth=${position}`);
|
|
124
|
-
// Playwright's getByRole with nth
|
|
125
|
-
selectors.push(`getByRole('${role}').nth(${position})`);
|
|
126
|
-
}
|
|
127
|
-
// nth-match by tag
|
|
128
|
-
if (tag) {
|
|
129
|
-
selectors.push(`${tag} >> nth=${position}`);
|
|
130
|
-
selectors.push(`locator('${tag}').nth(${position})`);
|
|
131
|
-
}
|
|
132
|
-
// Special case: first or last
|
|
133
|
-
if (position === 0) {
|
|
134
|
-
if (role)
|
|
135
|
-
selectors.push(`[role="${role}"] >> first`);
|
|
136
|
-
if (tag)
|
|
137
|
-
selectors.push(`${tag} >> first`);
|
|
138
|
-
}
|
|
139
|
-
else if (position === siblingsWithSameRole.length - 1) {
|
|
140
|
-
if (role)
|
|
141
|
-
selectors.push(`[role="${role}"] >> last`);
|
|
142
|
-
if (tag)
|
|
143
|
-
selectors.push(`${tag} >> last`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return selectors;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Strategy 4: Generic fallbacks (last resort)
|
|
150
|
-
*/
|
|
151
|
-
generateGenericFallbacks(element) {
|
|
152
|
-
const selectors = [];
|
|
153
|
-
const { tag, role, text, type } = element;
|
|
154
|
-
// Text content
|
|
155
|
-
if (text && text.length > 0 && text.length < 30) {
|
|
156
|
-
selectors.push(`text=${this.escape(text)}`);
|
|
157
|
-
selectors.push(`getByText('${this.escape(text)}')`);
|
|
158
|
-
}
|
|
159
|
-
// Role only (use first())
|
|
160
|
-
if (role) {
|
|
161
|
-
selectors.push(`[role="${role}"] >> first`);
|
|
162
|
-
selectors.push(`getByRole('${role}').first()`);
|
|
163
|
-
}
|
|
164
|
-
// Type selector
|
|
165
|
-
if (type) {
|
|
166
|
-
selectors.push(`${tag}[type="${type}"] >> first`);
|
|
167
|
-
}
|
|
168
|
-
// Ultimate fallback
|
|
169
|
-
selectors.push(`${tag} >> first`);
|
|
170
|
-
return selectors;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Walk ARIA tree to find path from root to target ref
|
|
174
|
-
*/
|
|
175
|
-
getAriaTreePath(tree, targetRef) {
|
|
176
|
-
const path = [];
|
|
177
|
-
const found = this.walkTree(tree, targetRef, path);
|
|
178
|
-
if (found) {
|
|
179
|
-
return {
|
|
180
|
-
nodes: path,
|
|
181
|
-
targetIndex: path.length - 1
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
walkTree(node, targetRef, path) {
|
|
187
|
-
if (!node)
|
|
188
|
-
return false;
|
|
189
|
-
// Add current node to path
|
|
190
|
-
path.push(node);
|
|
191
|
-
// Found it!
|
|
192
|
-
if (node.ref === targetRef) {
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
// Search children
|
|
196
|
-
if (node.children && Array.isArray(node.children)) {
|
|
197
|
-
for (const child of node.children) {
|
|
198
|
-
if (this.walkTree(child, targetRef, path)) {
|
|
199
|
-
return true; // Found in this subtree
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
// Not found in this subtree - backtrack
|
|
204
|
-
path.pop();
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
escape(str) {
|
|
208
|
-
return str.replace(/'/g, "\\'").replace(/"/g, '\\"');
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
exports.HierarchicalSelectorGenerator = HierarchicalSelectorGenerator;
|
|
212
|
-
//# sourceMappingURL=hierarchical-selector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hierarchical-selector.js","sourceRoot":"","sources":["../../src/utils/hierarchical-selector.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAcH,MAAa,6BAA6B;IAGxC,YAAY,MAAoE;QAC9E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,uBAAuB,CACrB,GAAW,EACX,MA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O,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;CACF;AA1PD,sEA0PC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ref Attacher - Injects stable refs as data-tc-id attributes into the DOM
|
|
3
|
-
* This makes refs stable across agent invocations and translations
|
|
4
|
-
*/
|
|
5
|
-
import { PageInfo } from './page-info-utils';
|
|
6
|
-
export interface RefAttacherResult {
|
|
7
|
-
success: boolean;
|
|
8
|
-
refsAttached: number;
|
|
9
|
-
pageInfo: PageInfo;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Attach refs from ARIA tree as data-tc-id attributes in the DOM
|
|
13
|
-
* This ensures refs are stable and can be used by both agent and translator
|
|
14
|
-
*/
|
|
15
|
-
export declare function attachRefsToDOM(page: any): Promise<RefAttacherResult>;
|
|
16
|
-
/**
|
|
17
|
-
* Get page info using existing data-tc-id attributes
|
|
18
|
-
* This allows using stable refs without regenerating them
|
|
19
|
-
*/
|
|
20
|
-
export declare function getPageInfoFromAttachedRefs(page: any): Promise<PageInfo>;
|
|
21
|
-
//# sourceMappingURL=ref-attacher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ref-attacher.d.ts","sourceRoot":"","sources":["../../src/utils/ref-attacher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAkH3E;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0C9E"}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Ref Attacher - Injects stable refs as data-tc-id attributes into the DOM
|
|
4
|
-
* This makes refs stable across agent invocations and translations
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.attachRefsToDOM = attachRefsToDOM;
|
|
8
|
-
exports.getPageInfoFromAttachedRefs = getPageInfoFromAttachedRefs;
|
|
9
|
-
const page_info_utils_1 = require("./page-info-utils");
|
|
10
|
-
/**
|
|
11
|
-
* Attach refs from ARIA tree as data-tc-id attributes in the DOM
|
|
12
|
-
* This ensures refs are stable and can be used by both agent and translator
|
|
13
|
-
*/
|
|
14
|
-
async function attachRefsToDOM(page) {
|
|
15
|
-
try {
|
|
16
|
-
// 1. Get page info with refs generated
|
|
17
|
-
const pageInfo = await (0, page_info_utils_1.getEnhancedPageInfo)(page);
|
|
18
|
-
if (!pageInfo.refMap || pageInfo.refMap.size === 0) {
|
|
19
|
-
return {
|
|
20
|
-
success: false,
|
|
21
|
-
refsAttached: 0,
|
|
22
|
-
pageInfo
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
// 2. Build a mapping of element characteristics to refs
|
|
26
|
-
const refMappings = [];
|
|
27
|
-
pageInfo.refMap.forEach((element, ref) => {
|
|
28
|
-
refMappings.push({
|
|
29
|
-
ref,
|
|
30
|
-
tag: element.tag,
|
|
31
|
-
role: element.role,
|
|
32
|
-
text: element.text || '',
|
|
33
|
-
name: element.name || '',
|
|
34
|
-
placeholder: element.placeholder || '',
|
|
35
|
-
type: element.type || '',
|
|
36
|
-
ariaLabel: element.ariaLabel || ''
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
// 3. Inject refs into DOM as data-tc-id attributes
|
|
40
|
-
const refsAttached = await page.evaluate((mappings) => {
|
|
41
|
-
let attached = 0;
|
|
42
|
-
const doc = globalThis.document;
|
|
43
|
-
// Get all elements
|
|
44
|
-
const allElements = Array.from(doc.querySelectorAll('*'));
|
|
45
|
-
for (const mapping of mappings) {
|
|
46
|
-
// Try to find matching element in DOM
|
|
47
|
-
let matchedElement = null;
|
|
48
|
-
// Strategy 1: Match by name attribute (most reliable for inputs)
|
|
49
|
-
if (mapping.name) {
|
|
50
|
-
matchedElement = doc.querySelector(`${mapping.tag}[name="${mapping.name}"]`);
|
|
51
|
-
}
|
|
52
|
-
// Strategy 2: Match by placeholder
|
|
53
|
-
if (!matchedElement && mapping.placeholder) {
|
|
54
|
-
matchedElement = doc.querySelector(`${mapping.tag}[placeholder="${mapping.placeholder}"]`);
|
|
55
|
-
}
|
|
56
|
-
// Strategy 3: Match by aria-label
|
|
57
|
-
if (!matchedElement && mapping.ariaLabel) {
|
|
58
|
-
matchedElement = doc.querySelector(`${mapping.tag}[aria-label="${mapping.ariaLabel}"]`);
|
|
59
|
-
}
|
|
60
|
-
// Strategy 4: Match by text content (for buttons, labels, etc.)
|
|
61
|
-
if (!matchedElement && mapping.text && mapping.text.length > 0 && mapping.text.length < 100) {
|
|
62
|
-
for (const el of allElements) {
|
|
63
|
-
const element = el;
|
|
64
|
-
if (element.tagName.toLowerCase() === mapping.tag &&
|
|
65
|
-
element.textContent?.trim() === mapping.text.trim()) {
|
|
66
|
-
matchedElement = el;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// Strategy 5: Match by role and index (fallback)
|
|
72
|
-
if (!matchedElement && mapping.role) {
|
|
73
|
-
const roleElements = Array.from(doc.querySelectorAll(`[role="${mapping.role}"]`));
|
|
74
|
-
if (roleElements.length > 0) {
|
|
75
|
-
// Use first matching role element that doesn't have a ref yet
|
|
76
|
-
for (const el of roleElements) {
|
|
77
|
-
const element = el;
|
|
78
|
-
if (!element.hasAttribute('data-tc-id')) {
|
|
79
|
-
matchedElement = el;
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
// Attach ref as data-tc-id
|
|
86
|
-
if (matchedElement && !matchedElement.hasAttribute('data-tc-id')) {
|
|
87
|
-
matchedElement.setAttribute('data-tc-id', mapping.ref);
|
|
88
|
-
attached++;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return attached;
|
|
92
|
-
}, refMappings);
|
|
93
|
-
console.log(`[RefAttacher] ✓ Attached ${refsAttached} refs to DOM as data-tc-id`);
|
|
94
|
-
return {
|
|
95
|
-
success: true,
|
|
96
|
-
refsAttached,
|
|
97
|
-
pageInfo
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
console.error(`[RefAttacher] ✗ Failed to attach refs: ${error.message}`);
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Get page info using existing data-tc-id attributes
|
|
107
|
-
* This allows using stable refs without regenerating them
|
|
108
|
-
*/
|
|
109
|
-
async function getPageInfoFromAttachedRefs(page) {
|
|
110
|
-
// Get base page info
|
|
111
|
-
const pageInfo = await (0, page_info_utils_1.getEnhancedPageInfo)(page);
|
|
112
|
-
// Extract refs from data-tc-id attributes
|
|
113
|
-
const domRefs = await page.evaluate(() => {
|
|
114
|
-
const doc = globalThis.document;
|
|
115
|
-
const elementsWithRefs = Array.from(doc.querySelectorAll('[data-tc-id]'));
|
|
116
|
-
return elementsWithRefs.map((el) => ({
|
|
117
|
-
ref: el.getAttribute('data-tc-id'),
|
|
118
|
-
tag: el.tagName.toLowerCase(),
|
|
119
|
-
role: el.getAttribute('role') || '',
|
|
120
|
-
text: el.textContent?.trim().substring(0, 100) || '',
|
|
121
|
-
name: el.getAttribute('name') || '',
|
|
122
|
-
placeholder: el.getAttribute('placeholder') || '',
|
|
123
|
-
type: el.getAttribute('type') || '',
|
|
124
|
-
ariaLabel: el.getAttribute('aria-label') || ''
|
|
125
|
-
}));
|
|
126
|
-
});
|
|
127
|
-
// Merge DOM refs into refMap
|
|
128
|
-
const updatedRefMap = new Map(pageInfo.refMap);
|
|
129
|
-
domRefs.forEach((item) => {
|
|
130
|
-
if (item.ref && !updatedRefMap.has(item.ref)) {
|
|
131
|
-
updatedRefMap.set(item.ref, {
|
|
132
|
-
tag: item.tag,
|
|
133
|
-
role: item.role,
|
|
134
|
-
text: item.text,
|
|
135
|
-
name: item.name,
|
|
136
|
-
placeholder: item.placeholder,
|
|
137
|
-
type: item.type,
|
|
138
|
-
ariaLabel: item.ariaLabel,
|
|
139
|
-
id: null,
|
|
140
|
-
selectors: []
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
return {
|
|
145
|
-
...pageInfo,
|
|
146
|
-
refMap: updatedRefMap
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=ref-attacher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ref-attacher.js","sourceRoot":"","sources":["../../src/utils/ref-attacher.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAcH,0CAkHC;AAMD,kEA0CC;AA9KD,uDAAkE;AAQlE;;;GAGG;AACI,KAAK,UAAU,eAAe,CAAC,IAAS;IAC7C,IAAI,CAAC;QACH,uCAAuC;QACvC,MAAM,QAAQ,GAAG,MAAM,IAAA,qCAAmB,EAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACnD,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE,CAAC;gBACf,QAAQ;aACT,CAAC;QACJ,CAAC;QAED,wDAAwD;QACxD,MAAM,WAAW,GASZ,EAAE,CAAC;QAER,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,E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archical ARIA tree context for robust selector generation
|
|
5
|
-
*/
|
|
6
|
-
import { RefCommand } from '../orchestrator/types';
|
|
7
|
-
export declare class RefTranslator {
|
|
8
|
-
private logger?;
|
|
9
|
-
private hierarchicalGenerator;
|
|
10
|
-
constructor(logger?: (message: string, level?: 'log' | 'error' | 'warn') => void);
|
|
11
|
-
/**
|
|
12
|
-
* LEGACY: Translate string commands (supports regex getByRef pattern)
|
|
13
|
-
* Use translateRefCommands() instead for new code
|
|
14
|
-
*/
|
|
15
|
-
translateStringCommands(commands: string[], page: any, refMap?: Map<string, any>, ariaTree?: any): Promise<Array<{
|
|
16
|
-
original: string;
|
|
17
|
-
alternatives: string[];
|
|
18
|
-
successful?: string;
|
|
19
|
-
}>>;
|
|
20
|
-
/**
|
|
21
|
-
* Translation layer: Convert ref commands to actual Playwright commands
|
|
22
|
-
* Tries multiple selector alternatives until one succeeds
|
|
23
|
-
*
|
|
24
|
-
* Agent outputs:
|
|
25
|
-
* { ref: 'e22', operation: 'fill', value: 'test@test.com' }
|
|
26
|
-
* This generates and tries multiple Playwright alternatives using hierarchical context
|
|
27
|
-
* Returns: The command that worked (for script storage)
|
|
28
|
-
*/
|
|
29
|
-
translateRefCommands(refCommands: RefCommand[], page: any, refMap?: Map<string, any>, ariaTree?: any): Promise<Array<{
|
|
30
|
-
original: RefCommand;
|
|
31
|
-
alternatives: string[];
|
|
32
|
-
successful?: string;
|
|
33
|
-
}>>;
|
|
34
|
-
/**
|
|
35
|
-
* Generate drag commands with coordinates
|
|
36
|
-
*/
|
|
37
|
-
private generateDragCommands;
|
|
38
|
-
/**
|
|
39
|
-
* Convert selectors to full Playwright commands with action
|
|
40
|
-
*/
|
|
41
|
-
private convertSelectorsToCommands;
|
|
42
|
-
/**
|
|
43
|
-
* Convert selector string to locator chain for building commands
|
|
44
|
-
*/
|
|
45
|
-
private selectorToLocatorChain;
|
|
46
|
-
private getActionCode;
|
|
47
|
-
private escape;
|
|
48
|
-
}
|
|
49
|
-
//# sour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