Skip to content

LangChain Playwright Toolkit

Category: Classic

Package: langchain-community (Python)

Cost: Free / open source

Official docs: https://python.langchain.com/docs/integrations/toolkits/playwright

GitHub source: langchain-ai/langchain (libs/langchain/langchain_classic/agents/agent_toolkits/playwright)


What it is

PlayWrightBrowserToolkit is a LangChain BaseToolkit that wraps Microsoft Playwright and exposes seven browser-control tools an LLM agent can call by name. It ships as part of langchain-community and lets you give any LangChain agent the ability to navigate pages, click elements, read text, extract links, and inspect the DOM inside a real Chromium, Firefox, or WebKit browser.

The toolkit supports both a sync and an async Playwright browser. You pass one in at construction time; the toolkit wires it to every tool automatically.

Included tools

Tool classTool name (used by the agent)What it does
NavigateToolnavigate_browserNavigate to a URL (http/https only by default)
NavigateBackToolprevious_webpageGo back one page in browser history
ClickToolclick_elementClick a DOM element by CSS selector
ExtractTextToolextract_textExtract visible text from the current page
ExtractHyperlinksToolextract_hyperlinksExtract all hyperlinks from the current page
GetElementsToolget_elementsGet DOM elements matching a CSS selector
CurrentWebPageToolcurrent_webpageReturn the URL of the current page

Security note

By default the toolkit allows navigation to any URL, including internal network addresses and local files. When exposing this toolkit to end users, restrict network access on the host or subclass NavigateTool with a custom args_schema that limits permitted URL prefixes. See https://python.langchain.com/docs/security.

Free vs paid

Completely free and open source (MIT licence via the langchain-community package). Playwright itself is also free (Apache 2.0). No API key required.

Template / starter

No official downloadable boilerplate exists. The usage pattern is short enough that the code on the Usage page is the canonical starting point.