diff --git a/scripts/test.mjs b/scripts/test.mjs index 403bcd5d..5605156f 100644 --- a/scripts/test.mjs +++ b/scripts/test.mjs @@ -53,7 +53,7 @@ const nodeArgs = [ 'spec', '--test-force-exit', '--test', - '--test-timeout=30000', + '--test-timeout=60000', ...flags, ...files, ]; diff --git a/src/tools/input.ts b/src/tools/input.ts index bfbcf6b6..46e68fcd 100644 --- a/src/tools/input.ts +++ b/src/tools/input.ts @@ -159,7 +159,12 @@ async function fillFormElement( if (aXNode && aXNode.role === 'combobox') { await selectOption(handle, aXNode, value); } else { - await handle.asLocator().fill(value); + // Increase timeout for longer input values. + const timeoutPerChar = 10; // ms + const fillTimeout = + context.getSelectedPage().getDefaultTimeout() + + value.length * timeoutPerChar; + await handle.asLocator().setTimeout(fillTimeout).fill(value); } } finally { void handle.dispose(); @@ -183,6 +188,7 @@ export const fill = defineTool({ }, handler: async (request, response, context) => { await context.waitForEventsAfterAction(async () => { + await context.getSelectedPage().keyboard.type(request.params.value); await fillFormElement( request.params.uid, request.params.value, diff --git a/tests/tools/input.test.ts b/tests/tools/input.test.ts index cb8ae711..0150671c 100644 --- a/tests/tools/input.test.ts +++ b/tests/tools/input.test.ts @@ -301,6 +301,38 @@ describe('input', () => { assert.strictEqual(selectedValue, 'v2'); }); }); + + it('fills out a textarea with long text', async () => { + await withMcpContext(async (response, context) => { + const page = context.getSelectedPage(); + await page.setContent(html`