@@ -11,17 +11,18 @@ class BrowserbaseConnection(RemoteConnection):
11
11
"""
12
12
13
13
browserbase_session : SessionCreateResponse
14
+ session_id : str
14
15
15
- def __init__ (self , * args , ** kwargs ):
16
- self .browserbase_session = bb .sessions .create (project_id = BROWSERBASE_PROJECT_ID )
16
+ def __init__ (self , session_id : str , * args , ** kwargs ):
17
17
super ().__init__ (* args , ** kwargs )
18
+ self .session_id = session_id
18
19
19
20
def get_remote_connection_headers (self , parsed_url , keep_alive = False ):
20
21
headers = super ().get_remote_connection_headers (parsed_url , keep_alive )
21
22
22
23
# Update headers to include the Browserbase required information
23
24
headers ["x-bb-api-key" ] = BROWSERBASE_API_KEY
24
- headers ["session-id" ] = self .browserbase_session . id
25
+ headers ["session-id" ] = self .session_id
25
26
26
27
return headers
27
28
@@ -37,7 +38,8 @@ def run(driver: WebDriver):
37
38
38
39
39
40
# Use the custom class to create and connect to a new browser session
40
- connection = BrowserbaseConnection ("http://connect.browserbase.com/webdriver" )
41
+ session = bb .sessions .create (project_id = BROWSERBASE_PROJECT_ID )
42
+ connection = BrowserbaseConnection (session .id , session .selenium_remote_url )
41
43
driver = webdriver .Remote (connection , options = webdriver .ChromeOptions ())
42
44
43
45
# Print a bit of info about the browser we've connected to
0 commit comments