@cutleryapp/agent 1.0.40 → 1.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/mcp-executor.js +37 -7
- package/package.json +1 -1
package/dist/mcp-executor.js
CHANGED
|
@@ -334,14 +334,36 @@ class TestExecutor {
|
|
|
334
334
|
const optionValue = selMatch[1].trim();
|
|
335
335
|
const fieldLabel = selMatch[2].trim();
|
|
336
336
|
let selHandled = false;
|
|
337
|
-
// 1. Native <select> —
|
|
338
|
-
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
337
|
+
// 1. Native <select> — try by label, name, id
|
|
338
|
+
if (!selHandled) {
|
|
339
|
+
const fieldRe = new RegExp(fieldLabel.replace(/[\s_-]+/g, '[\\s_-]*'), 'i');
|
|
340
|
+
const selectLocators = [
|
|
341
|
+
page.getByLabel(fieldRe),
|
|
342
|
+
page.locator(`select[name*="${fieldLabel}" i]`),
|
|
343
|
+
page.locator(`select[id*="${fieldLabel}" i]`),
|
|
344
|
+
page.locator(`select[data-test*="${fieldLabel}" i]`),
|
|
345
|
+
];
|
|
346
|
+
for (const loc of selectLocators) {
|
|
347
|
+
try {
|
|
348
|
+
const el = loc.first();
|
|
349
|
+
const tag = await el.evaluate((n) => n.tagName.toLowerCase()).catch(() => '');
|
|
350
|
+
if (tag !== 'select')
|
|
351
|
+
continue; // only drive actual <select> elements
|
|
352
|
+
// Try matching by label text, then by value
|
|
353
|
+
const matched = await Promise.any([
|
|
354
|
+
el.selectOption({ label: optionValue }, { timeout: 1000 }),
|
|
355
|
+
el.selectOption({ value: optionValue }, { timeout: 1000 }),
|
|
356
|
+
el.selectOption(optionValue, { timeout: 1000 }),
|
|
357
|
+
]).then(() => true).catch(() => false);
|
|
358
|
+
if (matched) {
|
|
359
|
+
selHandled = true;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
catch { /* next */ }
|
|
364
|
+
}
|
|
342
365
|
}
|
|
343
|
-
|
|
344
|
-
// 2. Radio / checkbox label click — do this BEFORE autocomplete so radio buttons
|
|
366
|
+
// 2. Radio / checkbox label click — before autocomplete so radio buttons
|
|
345
367
|
// are handled in <100ms instead of waiting through autocomplete timeouts
|
|
346
368
|
if (!selHandled) {
|
|
347
369
|
try {
|
|
@@ -367,6 +389,14 @@ class TestExecutor {
|
|
|
367
389
|
await page.locator(`[role="option"]:has-text("${optionValue}"), [class*="option"]:has-text("${optionValue}")`).first().click({ timeout: 1000 });
|
|
368
390
|
selHandled = true;
|
|
369
391
|
}
|
|
392
|
+
catch { /* try text input fallback */ }
|
|
393
|
+
}
|
|
394
|
+
// 5. Text input / textarea fallback — handles "Select X in Y" where Y is a textarea
|
|
395
|
+
if (!selHandled) {
|
|
396
|
+
try {
|
|
397
|
+
await tryFill(page, fieldLabel, optionValue);
|
|
398
|
+
selHandled = true;
|
|
399
|
+
}
|
|
370
400
|
catch { /* fall to AI */ }
|
|
371
401
|
}
|
|
372
402
|
if (selHandled)
|