@cutleryapp/agent 1.0.10 → 1.0.12
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/mcp-executor.js +19 -22
- package/package.json +1 -1
package/dist/mcp-executor.js
CHANGED
|
@@ -92,26 +92,22 @@ class TestExecutor {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
else if (lower.includes("fill") || lower.includes("type") || lower.includes("enter")) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// label can match placeholder/aria/data-test/label etc.
|
|
95
|
+
// Support both quoted and unquoted formats:
|
|
96
|
+
// Fill "standard_user" in "Username"
|
|
97
|
+
// Fill standard_user in Username field
|
|
98
|
+
// Split on first " in " / " into " to separate value from field
|
|
99
|
+
const match = raw.match(/(?:enter|fill|type)\s+"([^"]+)"\s+(?:in|into)\s+(?:the\s+)?"?([^"]+?)"?\s*(?:field|input|box|area)?\s*$/i) ||
|
|
100
|
+
raw.match(/(?:enter|fill|type)\s+(\S+)\s+(?:in|into)\s+(?:the\s+)?(.+?)\s*(?:field|input|box|area)?\s*$/i);
|
|
101
|
+
if (match) {
|
|
102
|
+
const value = match[1].trim();
|
|
103
|
+
const fieldLabel = match[2].trim();
|
|
105
104
|
const looksLikeCss = (s) => /[#.\[\]:>]/.test(s);
|
|
106
|
-
if (
|
|
107
|
-
await page.waitForSelector(
|
|
108
|
-
await page.fill(
|
|
105
|
+
if (looksLikeCss(fieldLabel)) {
|
|
106
|
+
await page.waitForSelector(fieldLabel, { state: "visible", timeout: 5000 });
|
|
107
|
+
await page.fill(fieldLabel, value);
|
|
109
108
|
}
|
|
110
|
-
else
|
|
111
|
-
await tryFill(page,
|
|
112
|
-
}
|
|
113
|
-
else if (bareLabel) {
|
|
114
|
-
await tryFill(page, bareLabel.trim(), value);
|
|
109
|
+
else {
|
|
110
|
+
await tryFill(page, fieldLabel, value);
|
|
115
111
|
}
|
|
116
112
|
}
|
|
117
113
|
}
|
|
@@ -223,11 +219,12 @@ async function tryClick(page, nameRe, label) {
|
|
|
223
219
|
}
|
|
224
220
|
async function tryClickScoped(page, nameRe, target, scope) {
|
|
225
221
|
const FAST = 3000;
|
|
226
|
-
//
|
|
222
|
+
// Strip trailing generic nouns that won't appear verbatim on the page
|
|
223
|
+
const cleanScope = scope.replace(/\s+(?:product|item|section|card|row|container|element|button|link|area|panel|block)$/i, '').trim();
|
|
227
224
|
const strategies = [
|
|
228
|
-
() => page.locator(`:has-text("${
|
|
229
|
-
() => page.locator(`:has-text("${
|
|
230
|
-
() => page.locator(`:has-text("${
|
|
225
|
+
() => page.locator(`:has-text("${cleanScope}")`).last().getByRole('button', { name: nameRe }).first().click({ timeout: FAST }),
|
|
226
|
+
() => page.locator(`:has-text("${cleanScope}")`).last().getByRole('link', { name: nameRe }).first().click({ timeout: FAST }),
|
|
227
|
+
() => page.locator(`:has-text("${cleanScope}")`).last().getByText(nameRe).first().click({ timeout: FAST }),
|
|
231
228
|
// Fallback: ignore scope and click anywhere
|
|
232
229
|
() => page.getByRole('button', { name: nameRe }).first().click({ timeout: FAST }),
|
|
233
230
|
() => page.getByText(nameRe).first().click({ timeout: FAST }),
|