stagehand icon indicating copy to clipboard operation
stagehand copied to clipboard

Bring your own browser?

Open AdamGoodApp opened this issue 11 months ago • 3 comments

I have my own browser instance running that I would like Stagehand to attach to.

Is this possible?

AdamGoodApp avatar Jan 09 '25 07:01 AdamGoodApp

can you say more? What kind of browser and where is it running? we do support a local mode currently.

filip-michalsky avatar Jan 09 '25 14:01 filip-michalsky

+1 for this one. I wish there was an option to pass in a custom Playwright Browser through the config

Use cases:

  • To be able to attach cookies / browser extensions
  • To be able to use custom chrome builds
  • To be able to use firefox / safari

At work I am forced to use a corporate laptop, on which all the browsers are blocked except for chrome on a specific path Hence, playwright does not work, unless I specify the path to the chrome manually

marchellodev avatar Jan 09 '25 20:01 marchellodev

can you say more? What kind of browser and where is it running? we do support a local mode currently.

I have a Chromium browser running in a docker container I would like stagehand to attach to.

AdamGoodApp avatar Jan 10 '25 01:01 AdamGoodApp

Hey!

Multiple browsers is unfortunately not on the roadmap as of now. We want Stagehand to be really really good on Chrome, and our roadmap is actually more likely to include performance upgrades for users running on Chrome at the cost of degraded support for Firefox/Safari.

If you're interested in browser customization, I highly recommend checking out Browserbase for stuff like custom contexts and extensions while we work on implementing those features natively in Stagehand

kamath avatar Jan 18 '25 22:01 kamath

@kamath He meant attaching to an existing browser session.

shuangg avatar Jan 23 '25 17:01 shuangg

yeah ifi have a chromium running on my own server could i point stagehand at that wss:// browser CDP protocol and control it the same way, it shoudl work theoretically

rdvo avatar Jan 31 '25 03:01 rdvo

I would like to do something like this

import { chromium } from 'playwright-extra'

const browser = await chromium.launch()

const context = await browser.newContext({
    // custom state
    storageState: loadStorageState(),
})

const stagehand = new Stagehand({
  ...StagehandConfig,
  // Use your own context
  context,
})

miekassu avatar Feb 02 '25 00:02 miekassu

I'd really like to be able to connect to the local Chrome on my Mac via CDP, too. This is so I can re-use the cookies/localstorage in there

So I'd log into a bunch of systems in Chrome (including "hard to log into" ones) and then run the stagehand program

jonastemplestein avatar Feb 03 '25 16:02 jonastemplestein

Not being able to pass arguments to the Playwright context (i.e. browser.newContext({...}) is a major blocker.

This prevents Stagehand from being used in real-world projects that depend on options in Playwright’s BrowserContextOptions (docs).

I like @miekassu’s suggestion of passing through an existing context.

If that’s not feasible, could you add Playwright’s BrowserContextOptions to StagehandConfig so they can be passed to the internally created context?

misprintt avatar Feb 05 '25 07:02 misprintt

+1 for Chrome CDP support

We currently use tools to manage multiple browser "profiles" (each with their own cookies and storage) that are accessible via CDP.

Currently we maintain Playwright automation scripts for these profiles and we'd like to use Stagehand to simplify our automation workflow.

jackthedev avatar Feb 05 '25 22:02 jackthedev

Hi all! Copying over my comments from here:

  • I think it's a totally fair call out that we expose less configurability for local than we should.
  • Frankly, the reason for doing this is because the Stagehand team is quite small, and exposing configurations of the local browser introduce more variables for unreliability, so we're trying to be super thoughtful about what we add.
  • The Browserbase browser enables more configurability, because it's much easier for us to debug issues that are reported.
  • You always are welcome to maintain a fork of Stagehand. We're MIT licensed for a reason, and are very supportive of forks!

That all being said, I just opened https://github.com/browserbase/stagehand/pull/494 which should address some of the configurability feedback! I hope you can give it a try.

pkiv avatar Feb 17 '25 17:02 pkiv

@pkiv does that PR address the ability to use a custom playwright context? I don't see it anywhere, but I could be missing something.

watzon avatar Feb 19 '25 19:02 watzon

this is really important.

Shawns2759 avatar Mar 17 '25 19:03 Shawns2759

I'm using a self-hosted instance of https://github.com/browserless/browserless. Can it work with that?

rvveber avatar Dec 08 '25 12:12 rvveber