File tree 3 files changed +11
-4
lines changed
3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @browserbasehq/stagehand " : patch
3
+ ---
4
+
5
+ fix targetted extract issue with scrollintoview and not chunking correctly
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ export class ElementContainer extends StagehandContainer {
51
51
* @returns A promise that resolves once scrolling is finished.
52
52
*/
53
53
public async scrollTo ( offset : number ) : Promise < void > {
54
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1500 ) ) ;
54
55
this . el . scrollTo ( { top : offset , behavior : "smooth" } ) ;
55
56
await this . waitForScrollEnd ( ) ;
56
57
}
@@ -67,7 +68,7 @@ export class ElementContainer extends StagehandContainer {
67
68
if ( ! element ) {
68
69
this . el . scrollTo ( { top : 0 , behavior : "smooth" } ) ;
69
70
} else {
70
- element . scrollIntoView ( { behavior : "smooth" , block : "end" } ) ;
71
+ element . scrollIntoView ( ) ;
71
72
}
72
73
await this . waitForScrollEnd ( ) ;
73
74
}
Original file line number Diff line number Diff line change @@ -190,9 +190,10 @@ export async function processAllOfDom(xpath?: string) {
190
190
191
191
// Now check if the element “fits” in the container’s viewport
192
192
const scrollTargetHeight = scrollTarget . getViewportHeight ( ) ;
193
- const rect = candidateElementContainer . getBoundingClientRect ( ) ;
193
+ const candidateElementContainerHeight =
194
+ candidateElementContainer . scrollHeight ;
194
195
195
- if ( rect . height <= scrollTargetHeight ) {
196
+ if ( candidateElementContainerHeight <= scrollTargetHeight ) {
196
197
// Single-chunk approach
197
198
console . log (
198
199
"Element is smaller/equal to container’s viewport. Doing single chunk." ,
@@ -235,7 +236,7 @@ export async function processAllOfDom(xpath?: string) {
235
236
const startOffset = scrollTarget . getScrollPosition ( ) ;
236
237
const viewportHeight = scrollTarget . getViewportHeight ( ) ;
237
238
const maxScroll = candidateElementContainer
238
- ? startOffset + candidateElementContainer . getBoundingClientRect ( ) . height
239
+ ? startOffset + candidateElementContainer . scrollHeight
239
240
: scrollTarget . getScrollHeight ( ) ;
240
241
const chunkSize = viewportHeight ;
241
242
You can’t perform that action at this time.
0 commit comments