Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/tools/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ 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,
Expand Down
74 changes: 74 additions & 0 deletions tests/tools/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import {describe, it} from 'node:test';

import {McpResponse} from '../../src/McpResponse.js';
import {
click,
hover,
Expand Down Expand Up @@ -382,6 +383,79 @@ describe('input', () => {
);
});
});

it('reproduction: fill isolation', async () => {
await withMcpContext(async (_response, context) => {
const page = context.getSelectedPage();
await page.setContent(
html`<form>
<input
id="email"
value="user@test.com"
/>
<input
id="password"
type="password"
/>
</form>`,
);
await context.createTextSnapshot();

// Fill email
const response1 = new McpResponse();
await fill.handler(
{
params: {
uid: '1_1', // email input
value: 'new@test.com',
},
},
response1,
context,
);
assert.strictEqual(
response1.responseLines[0],
'Successfully filled out the element',
);

// Fill password
const response2 = new McpResponse();
await fill.handler(
{
params: {
uid: '1_2', // password input
value: 'secret',
},
},
response2,
context,
);
assert.strictEqual(
response2.responseLines[0],
'Successfully filled out the element',
);

// Verify values
const values = await page.evaluate(() => {
return {
email: (document.getElementById('email') as HTMLInputElement).value,
password: (document.getElementById('password') as HTMLInputElement)
.value,
};
});

assert.strictEqual(
values.email,
'new@test.com',
'Email should be updated correctly',
);
assert.strictEqual(
values.password,
'secret',
'Password should be updated correctly',
);
});
});
});

describe('drags', () => {
Expand Down