n8n-io/n8n · error · Error

select failed

Error message

select failed

What it means

Thrown by AgentBrowserAdapter.select as the fallback message when the `eval` command that sets the <select> value returned success === false with no error field. The select() method clicks the element first (to focus the SELECT), then runs an eval script that sets option.selected and dispatches a change event. The literal 'select failed' only appears when resp.error is null/undefined.

Source

Thrown at packages/@n8n/mcp-browser/src/adapters/agent-browser.ts:382

		if (options?.submit) await this.runAction(['press', 'Enter']);
	}

	async select(pageId: string, target: ElementTarget, values: string[]): Promise<string[]> {
		await this.switchToTab(pageId);
		// Click to focus the <select> element (agent-browser does not inject aria-ref attributes)
		await this.runAction(['click', this.resolveTarget(target)]);
		// Set the value on document.activeElement, which is the <select> after click
		const script =
			'(function(){' +
			'const el=document.activeElement;' +
			'if(!el||el.tagName!=="SELECT")return[];' +
			`const v=${JSON.stringify(values)};` +
			'Array.from(el.options).forEach(o=>o.selected=v.includes(o.value)||v.includes(o.text.trim()));' +
			"el.dispatchEvent(new Event('change',{bubbles:true}));" +
			'return Array.from(el.selectedOptions).map(o=>o.value);})()';
		const resp = await this.run(['eval', script]);
		if (!resp.success) throw new Error(resp.error ?? 'select failed');
		return Array.isArray(resp.data) ? (resp.data as string[]) : values;
	}

	async hover(pageId: string, target: ElementTarget): Promise<void> {
		await this.switchToTab(pageId);
		await this.runAction(['hover', this.resolveTarget(target)]);
	}

	async press(pageId: string, keys: string): Promise<void> {
		AgentBrowserAdapter.assertSafeArg(keys, 'key');
		await this.switchToTab(pageId);
		await this.runAction(['press', keys]);
	}

	async drag(_pageId: string, _from: ElementTarget, _to: ElementTarget): Promise<void> {
		await Promise.resolve();
		throw new UnsupportedOperationError('drag', this.name);
	}

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Take a fresh snapshot and confirm the target ref points to a real <select> element before calling select().
  2. For custom dropdown components, use click() to open and click() on options instead of select().
  3. Upgrade/pin the agent-browser CLI version to match the adapter's expected eval response shape.
  4. Check the gateway logs for the eval command that failed.

Example fix

// before — calling select on a custom dropdown
await adapter.select(pageId, { ref: '@e5' }, ['opt1']);

// after — confirm it's a SELECT first, fall back to clicks
const snap = await adapter.snapshot(pageId);
if (!/@e5[^]*SELECT/.test(snap.tree)) {
  await adapter.click(pageId, { ref: '@e5' }); // open
  await adapter.click(pageId, { ref: '@e9' }); // option
} else {
  await adapter.select(pageId, { ref: '@e5' }, ['opt1']);
}
Defensive patterns

Strategy: fallback

Type guard

function isSelectFailure(error: unknown): boolean {
  return error instanceof Error && /select failed/.test(error.message);
}

Try / catch

try {
  return await adapter.select(pageId, target, values);
} catch (err) {
  if (isSelectFailure(err)) {
    // custom dropdown — click to open, then click options
    await adapter.click(pageId, target);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling adapter.select(pageId, target, values) where the click on the target succeeds but the subsequent `agent-browser eval` of the selection script returns { success: false } with no error string. Happens when the focused activeElement is not a SELECT, or the eval hits a page navigation/security error and the CLI drops the message.

Common situations: The target was not actually a <select> after the click (e.g. it was a custom dropdown), so the eval's guard `if(!el||el.tagName!=="SELECT")return[]` returns empty; a page navigation happened between click and eval; the agent-browser CLI version changed its eval response shape.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/2df93cd9f99cf9b0. Report an issue: GitHub.