File tree Expand file tree Collapse file tree 4 files changed +13
-0
lines changed Expand file tree Collapse file tree 4 files changed +13
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @browserbasehq/stagehand " : patch
3
+ ---
4
+
5
+ Fix debugDom still showing chunks when set to false
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ function multiSelectorMapToSelectorMap(
22
22
}
23
23
24
24
function drawChunk ( selectorMap : Record < number , string > ) {
25
+ if ( ! window . showChunks ) return ;
25
26
cleanupMarkers ( ) ;
26
27
Object . entries ( selectorMap ) . forEach ( ( [ _index , selector ] ) => {
27
28
const element = document . evaluate (
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ export {};
2
2
declare global {
3
3
interface Window {
4
4
chunkNumber : number ;
5
+ showChunks ?: boolean ;
5
6
processDom : ( chunksSeen : Array < number > ) => Promise < {
6
7
outputString : string ;
7
8
selectorMap : Record < number , string [ ] > ;
Original file line number Diff line number Diff line change @@ -390,6 +390,9 @@ export class Stagehand {
390
390
const originalGoto = this . page . goto . bind ( this . page ) ;
391
391
this . page . goto = async ( url : string , options ?: any ) => {
392
392
const result = await originalGoto ( url , options ) ;
393
+ if ( this . debugDom ) {
394
+ await this . page . evaluate ( ( ) => ( window . showChunks = this . debugDom ) ) ;
395
+ }
393
396
await this . page . waitForLoadState ( "domcontentloaded" ) ;
394
397
await this . _waitForSettledDom ( ) ;
395
398
return result ;
@@ -456,6 +459,9 @@ export class Stagehand {
456
459
const originalGoto = this . page . goto . bind ( this . page ) ;
457
460
this . page . goto = async ( url : string , options ?: any ) => {
458
461
const result = await originalGoto ( url , options ) ;
462
+ if ( this . debugDom ) {
463
+ await this . page . evaluate ( ( ) => ( window . showChunks = this . debugDom ) ) ;
464
+ }
459
465
await this . page . waitForLoadState ( "domcontentloaded" ) ;
460
466
await this . _waitForSettledDom ( ) ;
461
467
return result ;
You can’t perform that action at this time.
0 commit comments