Skip to content

Commit 31f89b9

Browse files
committed
fix: remove special handling for comboboxes
1 parent 5e5b746 commit 31f89b9

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

src/tools/input.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,11 @@ async function fillFormElement(
185185
const handle = await context.getElementByUid(uid);
186186
try {
187187
const aXNode = context.getAXNodeByUid(uid);
188-
if (aXNode && aXNode.role === 'combobox') {
188+
if (
189+
aXNode &&
190+
aXNode.role === 'combobox' &&
191+
(await handle.evaluate(el => el.tagName.toLowerCase() === 'select'))
192+
) {
189193
await selectOption(handle, aXNode, value);
190194
} else {
191195
// Increase timeout for longer input values.

tests/tools/input.test.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,40 @@ describe('input', () => {
352352
});
353353
});
354354

355+
it('fills out a textarea marked as combobox', async () => {
356+
await withMcpContext(async (response, context) => {
357+
const page = context.getSelectedPage();
358+
await page.setContent(html`<textarea role="combobox" />`);
359+
await context.createTextSnapshot();
360+
await fill.handler(
361+
{
362+
params: {
363+
uid: '1_1',
364+
value: '1',
365+
},
366+
},
367+
response,
368+
context,
369+
);
370+
assert.strictEqual(
371+
response.responseLines[0],
372+
'Successfully filled out the element',
373+
);
374+
assert.ok(response.includeSnapshot);
375+
assert.ok(
376+
await page.evaluate(() => {
377+
return document.body.querySelector('textarea')?.value === '1';
378+
}),
379+
);
380+
});
381+
});
382+
355383
it('fills out a textarea with long text', async () => {
356384
await withMcpContext(async (response, context) => {
357385
const page = context.getSelectedPage();
358386
await page.setContent(html`<textarea />`);
359-
await page.focus('textarea');
360387
await context.createTextSnapshot();
361-
await page.setDefaultTimeout(1000);
388+
page.setDefaultTimeout(1000);
362389
await fill.handler(
363390
{
364391
params: {

0 commit comments

Comments
 (0)