@@ -3,73 +3,6 @@ import { Stagehand } from "@browserbasehq/stagehand";
3
3
import StagehandConfig from "@/evals/deterministic/stagehand.config" ;
4
4
5
5
test . 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
-
73
6
test ( "should handle console events" , async ( ) => {
74
7
const stagehand = new Stagehand ( StagehandConfig ) ;
75
8
await stagehand . init ( ) ;
@@ -94,7 +27,7 @@ test.describe("StagehandPage - page.on()", () => {
94
27
await stagehand . init ( ) ;
95
28
96
29
const page = stagehand . page ;
97
- await page . goto ( "https://example.com" ) ;
30
+ await page . goto ( "https://example.com" , { waitUntil : "commit" } ) ;
98
31
99
32
page . on ( "dialog" , async ( dialog ) => {
100
33
expect ( dialog . message ( ) ) . toBe ( "Test alert" ) ;
@@ -111,7 +44,7 @@ test.describe("StagehandPage - page.on()", () => {
111
44
await stagehand . init ( ) ;
112
45
113
46
const page = stagehand . page ;
114
- await page . goto ( "https://example.com" ) ;
47
+ await page . goto ( "https://example.com" , { waitUntil : "commit" } ) ;
115
48
116
49
const requests : string [ ] = [ ] ;
117
50
const responses : string [ ] = [ ] ;
@@ -124,7 +57,7 @@ test.describe("StagehandPage - page.on()", () => {
124
57
responses . push ( response . url ( ) ) ;
125
58
} ) ;
126
59
127
- await page . goto ( "https://example.com" ) ;
60
+ await page . goto ( "https://example.com" , { waitUntil : "commit" } ) ;
128
61
129
62
expect ( requests ) . toContain ( "https://example.com/" ) ;
130
63
expect ( responses ) . toContain ( "https://example.com/" ) ;
0 commit comments