Skip to main content
Playwright is an open-source automation tool developed by Microsoft that allows you to programmatically control and automate web browsers. It is designed for end-to-end testing, scraping, and automating tasks across various web browsers such as Chromium, Firefox, and WebKit.
This toolkit is used to interact with the browser. While other tools (like the Requests tools) are fine for static sites, PlayWright Browser toolkits let your agent navigate the web and interact with dynamically rendered sites. Some tools bundled within the PlayWright Browser toolkit include:
  • NavigateTool (navigate_browser) - navigate to a URL
  • NavigateBackTool (previous_page) - wait for an element to appear
  • ClickTool (click_element) - click on an element (specified by selector)
  • ExtractTextTool (extract_text) - use beautiful soup to extract text from the current web page
  • ExtractHyperlinksTool (extract_hyperlinks) - use beautiful soup to extract hyperlinks from the current web page
  • GetElementsTool (get_elements) - select elements by CSS selector
  • CurrentPageTool (current_page) - get the current page URL
Async function to create context and launch browser:

Instantiating a Browser Toolkit

It’s always recommended to instantiate using the from_browser method so that the browser context is properly initialized and managed, ensuring seamless interaction and resource optimization.

Use within an Agent

Several of the browser tools are StructuredTool’s, meaning they expect multiple arguments. These aren’t compatible (out of the box) with agents older than the STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.