@@ -3,73 +3,6 @@ import { Stagehand } from "@browserbasehq/stagehand";
33import StagehandConfig from "@/evals/deterministic/stagehand.config" ;
44
55test . describe ( "StagehandPage - page.on()" , ( ) => {
6- test ( "should click on the crewAI blog tab" , async ( ) => {
7- const stagehand = new Stagehand ( StagehandConfig ) ;
8- await stagehand . init ( ) ;
9-
10- const page = stagehand . page ;
11- await page . goto (
12- "https://docs.browserbase.com/integrations/crew-ai/introduction" ,
13- ) ;
14-
15- let clickPromise : Promise < void > ;
16-
17- page . on ( "popup" , async ( newPage ) => {
18- clickPromise = newPage . click (
19- "body > div.page-wrapper > div.navbar-2.w-nav > div.padding-global.top-bot > div > div.navigation-left > nav > a:nth-child(7)" ,
20- ) ;
21- } ) ;
22-
23- await page . goto (
24- "https://docs.browserbase.com/integrations/crew-ai/introduction" ,
25- ) ;
26-
27- await page . click (
28- "#content-area > div.relative.mt-8.prose.prose-gray.dark\\:prose-invert > p:nth-child(2) > a" ,
29- ) ;
30-
31- await clickPromise ;
32-
33- await stagehand . close ( ) ;
34- } ) ;
35-
36- test ( "should close the new tab and navigate to it on the existing page" , async ( ) => {
37- const stagehand = new Stagehand ( StagehandConfig ) ;
38- await stagehand . init ( ) ;
39-
40- const page = stagehand . page ;
41- await page . goto (
42- "https://docs.browserbase.com/integrations/crew-ai/introduction" ,
43- ) ;
44-
45- let navigatePromise : Promise < unknown > ;
46-
47- page . on ( "popup" , async ( newPage ) => {
48- navigatePromise = Promise . allSettled ( [
49- newPage . close ( ) ,
50- page . goto ( newPage . url ( ) , { waitUntil : "domcontentloaded" } ) ,
51- ] ) ;
52- } ) ;
53-
54- // Click on the crewAI blog tab
55- await page . click (
56- "#content-area > div.relative.mt-8.prose.prose-gray.dark\\:prose-invert > p:nth-child(2) > a" ,
57- ) ;
58-
59- await navigatePromise ;
60-
61- await page . click (
62- "body > div.page-wrapper > div.navbar-2.w-nav > div.padding-global.top-bot > div > div.navigation-left > nav > a:nth-child(3)" ,
63- ) ;
64-
65- await page . waitForLoadState ( "domcontentloaded" ) ;
66-
67- const currentUrl = page . url ( ) ;
68- expect ( currentUrl ) . toBe ( "https://www.crewai.com/open-source" ) ;
69-
70- await stagehand . close ( ) ;
71- } ) ;
72-
736 test ( "should handle console events" , async ( ) => {
747 const stagehand = new Stagehand ( StagehandConfig ) ;
758 await stagehand . init ( ) ;
@@ -94,7 +27,7 @@ test.describe("StagehandPage - page.on()", () => {
9427 await stagehand . init ( ) ;
9528
9629 const page = stagehand . page ;
97- await page . goto ( "https://example.com" ) ;
30+ await page . goto ( "https://example.com" , { waitUntil : "commit" } ) ;
9831
9932 page . on ( "dialog" , async ( dialog ) => {
10033 expect ( dialog . message ( ) ) . toBe ( "Test alert" ) ;
@@ -111,7 +44,7 @@ test.describe("StagehandPage - page.on()", () => {
11144 await stagehand . init ( ) ;
11245
11346 const page = stagehand . page ;
114- await page . goto ( "https://example.com" ) ;
47+ await page . goto ( "https://example.com" , { waitUntil : "commit" } ) ;
11548
11649 const requests : string [ ] = [ ] ;
11750 const responses : string [ ] = [ ] ;
@@ -124,7 +57,7 @@ test.describe("StagehandPage - page.on()", () => {
12457 responses . push ( response . url ( ) ) ;
12558 } ) ;
12659
127- await page . goto ( "https://example.com" ) ;
60+ await page . goto ( "https://example.com" , { waitUntil : "commit" } ) ;
12861
12962 expect ( requests ) . toContain ( "https://example.com/" ) ;
13063 expect ( responses ) . toContain ( "https://example.com/" ) ;
0 commit comments