File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @browserbasehq/stagehand " : patch
3
+ ---
4
+
5
+ fix: unable to act on/get content from some same process iframes
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
11
11
EncodedId ,
12
12
RichNode ,
13
13
ID_PATTERN ,
14
+ CdpFrame ,
14
15
} from "../../types/context" ;
15
16
import { StagehandPage } from "../StagehandPage" ;
16
17
import { LogLine } from "../../types/log" ;
@@ -442,12 +443,15 @@ export async function getCDPFrameId(
442
443
const rootResp = ( await sp . sendCDP ( "Page.getFrameTree" ) ) as unknown ;
443
444
const { frameTree : root } = rootResp as { frameTree : CdpFrameTree } ;
444
445
445
- const url = frame . url ( ) ;
446
+ const targetUrl : string = frame . url ( ) ;
446
447
let depth = 0 ;
447
448
for ( let p = frame . parentFrame ( ) ; p ; p = p . parentFrame ( ) ) depth ++ ;
448
449
450
+ const withFragment = ( f : CdpFrame ) : string => f . url + ( f . urlFragment ?? "" ) ;
451
+
449
452
const findByUrlDepth = ( node : CdpFrameTree , lvl = 0 ) : string | undefined => {
450
- if ( lvl === depth && node . frame . url === url ) return node . frame . id ;
453
+ if ( lvl === depth && withFragment ( node . frame ) === targetUrl )
454
+ return node . frame . id ;
451
455
for ( const child of node . childFrames ?? [ ] ) {
452
456
const id = findByUrlDepth ( child , lvl + 1 ) ;
453
457
if ( id ) return id ;
@@ -467,7 +471,7 @@ export async function getCDPFrameId(
467
471
468
472
return frameTree . frame . id ; // root of OOPIF
469
473
} catch ( err ) {
470
- throw new StagehandIframeError ( url , String ( err ) ) ;
474
+ throw new StagehandIframeError ( targetUrl , String ( err ) ) ;
471
475
}
472
476
}
473
477
You can’t perform that action at this time.
0 commit comments