Lines 555-595javascript
555 await page.waitForLoadState('domcontentloaded', { timeout: 5000 }).catch(() => { });
559 // 3a. Multi-field fill: "Fill firstname, lastname" → fill each with inferred value
560 if (!handled && /^(?:fill|type)\s+/i.test(raw) && !/\s+(?:in|into|with)\s+/i.test(raw)) {
561 const fieldsPart = raw.replace(/^(?:fill|type)\s+/i, "").trim();
562 const fields = fieldsPart.split(/,\s*/).map((f) => f.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
563 if (fields.length > 1) {
565 firstname: "John", first: "John", fname: "John",
566 lastname: "Smith", last: "Smith", lname: "Smith", surname: "Smith",
567 name: "John Smith", fullname: "John Smith",
568 email: "john.smith@example.com", emailaddress: "john.smith@example.com",
569 phone: "9876543210", mobile: "9876543210", phonenumber: "9876543210", mobilenumber: "9876543210",
570 address: "123 Test Street", currentaddress: "123 Test Street", streetaddress: "123 Test Street",
571 city: "New York", state: "New York",
572 zip: "10001", zipcode: "10001", postalcode: "10001",
573 dob: "01/01/1990", dateofbirth: "01/01/1990", birthdate: "01/01/1990",
574 age: "30", username: "john.smith",
575 password: "Test@1234", company: "Acme Corp",
576 subject: "Mathematics", subjects: "Mathematics",
577 message: "This is a test message.", comment: "Test comment.",
578 description: "Test description.",
580 for (const field of fields) {
581 const key = field.toLowerCase().replace(/[\s_-]+/g, "");
582 // Test data first, then AI default map, then fallback
583 const dataValue = varMap[field] ?? varMap[key] ??
584 Object.entries(varMap).find(([k]) => k.toLowerCase().replace(/[\s_-]+/g, "") === key)?.[1];
585 const value = dataValue ?? valueMap[key] ?? "Test Value";
586 const src = dataValue ? "test data" : "AI default";
587 console.log(` ⌨️ Multi-fill: "${field}" → "${value}" (${src})`);
589 await tryFill(page, field, value);
591 catch { /* ignore individual failures */ }