Documentation Index Fetch the complete documentation index at: https://docs.browserbase.com/llms.txt
Use this file to discover all available pages before exploring further.
Run end-to-end browser tests in consistent, isolated cloud environments. Browserbase gives you reliable infrastructure for automated testing workflows, whether you’re using Stagehand or Playwright.
Reduce flaky tests with predictable, isolated browser sessions
Debug failures with built-in session recordings and screenshots
Scale test runs across concurrent sessions without managing infrastructure
Test from different locations and viewports with proxies and configurable browser settings
Template
Get started quickly with a ready-to-use testing template.
Website Link Tester Clone, configure, and run in minutes
Example: Testing a login flow
To demonstrate automated testing with Browserbase, this example validates a login flow against a sample application.
Code example
import { Stagehand } from "@browserbasehq/stagehand" ;
import { z } from "zod" ;
import dotenv from "dotenv" ;
async function main () {
dotenv . config ();
// initialize stagehand
const stagehand = new Stagehand ({
env: "BROWSERBASE" ,
});
await stagehand . init ();
const page = stagehand . context . pages ()[ 0 ];
async function automatedLoginTest ( inputs : any ) {
// Navigate to the form
await page . goto ( "https://www.saucedemo.com/" );
await stagehand . act ( `Input Username: ${ inputs . username } ` );
await stagehand . act ( `Input Password: ${ inputs . password } ` );
await stagehand . act ( "Click Login Button" );
// take a screenshot of the page
await page . screenshot ({ path: "login_screenshot.png" });
// log the url
return page . url ();
}
const response = await automatedLoginTest ({
username: "standard_user" ,
password: "secret_sauce" ,
});
console . log ( response );
// close the stagehand session
await stagehand . close ();
}
main (). catch ( console . error );
import os
import asyncio
from stagehand import AsyncStagehand
from dotenv import load_dotenv
load_dotenv()
async def main ():
# initialize stagehand
client = AsyncStagehand(
browserbase_api_key = os.environ[ "BROWSERBASE_API_KEY" ],
model_api_key = os.environ[ "MODEL_API_KEY" ],
)
session = await client.sessions.create( model_name = "google/gemini-2.5-flash" )
async def automated_login_test ( inputs ):
# Navigate to the form
await session.navigate( url = "https://www.saucedemo.com/" )
await session.act( input = f "Input Username: { inputs[ 'username' ] } " )
await session.act( input = f "Input Password: { inputs[ 'password' ] } " )
await session.act( input = "Click Login Button" )
await automated_login_test({
"username" : "standard_user" ,
"password" : "secret_sauce" ,
})
# close the stagehand session
await session.end()
if __name__ == "__main__" :
asyncio.run(main())
Configuration options
Set up a consistent environment
Test in a predictable environment with the same Chrome version every time.
// Create a standardized session
const session = await bb . sessions . create ({
// Optional: Configure viewport size (desktop, mobile)
browserSettings: {
viewport: {
width: 1280 ,
height: 720
}
}
});
# Create a standardized session
session = bb.sessions.create(
# Optional: Configure viewport size (desktop, mobile)
browser_settings = {
"viewport" : {
"width" : 1280 ,
"height" : 720
}
}
)
Test from different locations
Test how your app behaves from different locations:
// Create a session with proxy support
const session = await bb . sessions . create ({
proxies: [
{
type: "browserbase" ,
geolocation: {
city: "New York" ,
state: "NY" ,
country: "US"
}
}
]
});
# Create a session with proxy support
session = bb.sessions.create(
proxies = [
{ "type" : "browserbase" ,
"geolocation" : {
"city" : "New York" ,
"state" : "NY" ,
"country" : "US"
}
}
]
)
Complete configuration options
Set the viewport, operating system, and full list of configuration options to customize your test environment.
Best practices
Record sessions
Every session is automatically recorded and available in the Browserbase dashboard. With Session Recording , you can watch the exact session execution to debug failures efficiently.
console . log ( `View session recording at https://browserbase.com/sessions/ ${ session . id } ` );
print ( f "View session recording at https://browserbase.com/sessions/ { session.id } " )
No extra setup required —session recording happens automatically, allowing
you to diagnose flaky tests and failures with ease.
Add metadata for easier organization:
const session = await bb . sessions . create ({
userMetadata: {
testName: "login_flow" ,
suite: "authentication"
}
});
session = bb.sessions.create(
user_metadata = {
"testName" : "login_flow" ,
"suite" : "authentication"
}
)
Capture screenshots
Capture screenshots at critical points for easier debugging.
// Take a screenshot
await page . screenshot ({ path: "login_screenshot.png" });
# Take a screenshot
await page.screenshot( path = "login_screenshot.png" )
Next steps
Session Inspector Learn how to use the Session Inspector to debug test failures
Session Metadata Organize and query your test sessions effectively
Proxies Test your application from different geographic locations
Screenshots and PDFs Capture visual evidence during test execution