Skip to main content
Glama

click

Click on web page elements using CSS selectors to automate browser interactions for testing or data extraction tasks.

Instructions

Click on an element by selector

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYes
page_idNo

Implementation Reference

  • The main handler logic for the 'click' tool, which retrieves the selector from arguments, gets the active page, clicks the element, and returns a confirmation message.
    elif name == "click": selector = arguments.get("selector") if not selector: raise ValueError("Selector is required") page = get_active_page(arguments.get("page_id")) await page.click(selector) return [types.TextContent(type="text", text=f"Clicked element at selector: {selector}")]
  • Registration of the 'click' tool in the list_tools() function, including name, description, and input schema definition.
    types.Tool( name="click", description="Click on an element by selector", inputSchema={ "type": "object", "properties": { "selector": {"type": "string"}, "page_id": {"type": "string"}, }, "required": ["selector"], }, ),
  • Helper function used by the 'click' handler (and others) to retrieve the active Playwright Page instance based on the provided page_id or the current default.
    def get_active_page(page_id: Optional[str] = None) -> Page: """Get the active page based on page_id or current default.""" global current_page_id if page_id is None: page_id = current_page_id if page_id not in pages: raise ValueError(f"Page not found: {page_id}") return pages[page_id]

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/misanthropic-ai/playwrite-mcp'

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