---
title: Use Stagehand to connect with TestingBot
description: Run Stagehand AI with TestingBot's remote browser grid. Test websites
  with powerful AI-driven automation.
source_url:
  html: https://testingbot.com/support/ai/integrations/stagehand
  md: https://testingbot.com/support/ai/integrations/stagehand/index.md
---
# TestingBot & Stagehand

Stagehand is an AI Browser Automation Framework that allows you to create and manage browser automation tasks using AI. It is available in both NodeJS and Python.

By connecting Stagehand to TestingBot's remote browser grid, you can run multiple AI-driven browser automation tasks in parallel, without the need to manage the browsers yourself. Each session is video recorded and available for replay in the TestingBot dashboard. You can run browsers from [various geographical locations](https://testingbot.com/support/web-automate/playwright/options#geo) and use different browser versions, on multiple operating systems.

## Connecting to a remote browser

To get started, please install these packages:

- Install the Stagehand library: `@browserbasehq/stagehand`
- Install the TestingBot library: `npm install testingbot-api`

We can now run a simple example. This will connect Stagehand with a remote TestingBot browser session. Use the AI prompt to test a specific scenario, by describing what you want to test in your own natural language.

    const { Stagehand } = require("@browserbasehq/stagehand");
    const TestingBot = require("testingbot-api");
    
    (async () => {
      const tb = new TestingBot({
        api_key: process.env.TESTINGBOT_KEY,
        api_secret: process.env.TESTINGBOT_SECRET
      });
    
      const options = {
        capabilities: {
          browserName: 'chrome',
          browserVersion: 'latest',
          platform: 'WIN11'
        }
      };
    
      const session = await tb.createSession(options);
    
      const stagehand = new Stagehand({
            env: "LOCAL",
            localBrowserLaunchOptions: {
                    cdpUrl: session['cdp_url']
            }
      });
    
      await stagehand.init();
      const page = stagehand.page;
    
      await page.goto("https://testingbot.com/pricing");
    
      const extractResult = await page.extract("Extract the pricing plans from this page");
      console.log(`Extract result:\n`, extractResult);
    
    })();

Make sure to replace `TESTINGBOT_KEY` and `TESTINGBOT_SECRET` with your actual TestingBot API key and secret.

In the example above, we create a new TestingBot session with the desired capabilities. We then pass the `cdpUrl` to Stagehand, which allows it to connect to the remote browser session on TestingBot.

You can now use Stagehand's AI capabilities to interact with the page, extract information, or perform other actions as needed.

For more information on using Stagehand, please refer to the [Stagehand documentation](https://docs.stagehand.dev/first-steps/quickstart).

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new)[Slack Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
