Skip to main content

Overview

Stagehand v3 can work alongside Selenium WebDriver, allowing both tools to operate on the same browser session simultaneously. This enables you to combine Stagehand’s AI-powered automation with Selenium’s precise element interactions.
Browserbase Only: This integration requires Browserbase. It does not work with env: "LOCAL" because Selenium needs a remote WebDriver endpoint.

Installation

Install Stagehand, Selenium, and the Browserbase SDK:

Quickstart

Create Shared Session

Use the Browserbase SDK to create a session that both tools can connect to:

Connect Stagehand

Initialize Stagehand with the session ID:

Connect Selenium

Use a custom HTTP agent with the session’s signing key:

Use Both Tools Together

Now both Stagehand and Selenium operate on the same browser:

Key Points

  • Shared Session: Both tools connect to the same Browserbase session
  • Signing Key: Selenium requires the session’s signingKey in HTTP headers
  • Remote URL: Use session.seleniumRemoteUrl for Selenium’s server endpoint
  • Concurrent Usage: Both tools can operate on the browser simultaneously
  • Cleanup: Close both Stagehand (await stagehand.close()) and Selenium (await driver.quit())

Next Steps

Agent

Automate entire workflows

Act

Execute actions on web pages

Extract

Extract structured data from pages

Observe

Observe and find elements on pages