Skip to main content
Glama

select

Automate dropdown selection in web testing by specifying a CSS selector and value to choose, enabling precise UI interaction for browser automation tasks.

Instructions

Select an option from a dropdown

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for the select element
valueYesValue to select

Implementation Reference

  • Implements the 'select' tool by evaluating JavaScript in the browser to find the select element by CSS selector, set its value, dispatch a change event, and return success message or error if element not found.
    async select(selector, value) {
      await this.ensureChromium();
      
      const result = await this.sendCDPCommand('Runtime.evaluate', {
        expression: `
          const select = document.querySelector('${selector}');
          if (select) {
            select.value = '${value}';
            select.dispatchEvent(new Event('change', { bubbles: true }));
            true;
          } else {
            false;
          }
        `,
        returnByValue: true
      });
      
      if (!result.result?.value) {
        throw new Error(`Select element not found: ${selector}`);
      }
      
      return {
        content: [{ type: 'text', text: `Selected '${value}' in ${selector}` }],
      };
    }
  • Schema definition for the 'select' tool, including name, description, and input schema requiring 'selector' and 'value' parameters.
      name: 'select',
      description: 'Select an option from a dropdown',
      inputSchema: {
        type: 'object',
        properties: {
          selector: {
            type: 'string',
            description: 'CSS selector for the select element',
          },
          value: {
            type: 'string',
            description: 'Value to select',
          },
        },
        required: ['selector', 'value'],
      },
    },
  • index.js:366-367 (registration)
    Registration of the 'select' tool handler in the CallToolRequestSchema switch statement, dispatching to the select method with parsed arguments.
      return await this.select(args.selector, args.value);
    case 'get_console_logs':

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nfodor/claude-arm64-browser'

If you have feedback or need assistance with the MCP directory API, please join our Discord server