Skip to main content
Glama
blackwhite084

Playwright Server MCP

playwright_click_text

Click web page elements by matching their text content for automated interaction during browser testing or web scraping tasks.

Instructions

Click an element on the page by its text content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText content of the element to click

Implementation Reference

  • The ClickTextToolHandler class provides the core implementation of the playwright_click_text tool. Its handle method clicks on the first visible element matching the given text using Playwright's text locator.
    class ClickTextToolHandler(ToolHandler): @update_page_after_click async def handle(self, name: str, arguments: dict | None) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: if not self._sessions: return [types.TextContent(type="text", text="No active session. Please create a new session first.")] session_id = list(self._sessions.keys())[-1] page = self._sessions[session_id]["page"] text = arguments.get("text") await page.locator(f"text={text}").nth(0).click() return [types.TextContent(type="text", text=f"Clicked element with text {text}")]
  • JSON Schema definition for the playwright_click_text tool, specifying the required 'text' parameter.
    types.Tool( name="playwright_click_text", description="Click an element on the page by its text content", inputSchema={ "type": "object", "properties": { "text": {"type": "string", "description": "Text content of the element to click"} }, "required": ["text"] } ),
  • Registration of the ClickTextToolHandler instance in the tool_handlers dictionary, which maps tool names to their handlers for execution via handle_call_tool.
    "playwright_click_text": ClickTextToolHandler(),

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/blackwhite084/playwright-plus-python-mcp'

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