clear dom cache after scroll to prevent stale extract data

This commit is contained in:
Laith Weinberger
2026-04-11 18:03:06 -04:00
parent 92d3d152a2
commit 534eaafe7a

View File

@@ -518,6 +518,11 @@ class DefaultActionWatchdog(BaseWatchdog):
raise BrowserError(error_msg)
try:
def invalidate_dom_cache() -> None:
if self.browser_session._dom_watchdog:
self.browser_session._dom_watchdog.clear_cache()
# Convert direction and amount to pixels
# Positive pixels = scroll down, negative = scroll up
pixels = event.amount if event.direction == 'down' else -event.amount
@@ -547,6 +552,7 @@ class DefaultActionWatchdog(BaseWatchdog):
# Wait a bit for the scroll to settle and DOM to update
await asyncio.sleep(0.2)
invalidate_dom_cache()
return None
# Perform target-level scroll
@@ -554,6 +560,7 @@ class DefaultActionWatchdog(BaseWatchdog):
# Note: We don't clear cached state here - let multi_act handle DOM change detection
# by explicitly rebuilding and comparing when needed
invalidate_dom_cache()
# Log success
self.logger.debug(f'📜 Scrolled {event.direction} by {event.amount} pixels')