fix block screenshot bug (#3361)

This commit is contained in:
LawyZheng
2025-09-05 02:31:29 +08:00
committed by GitHub
parent 309176ef4b
commit 9413958f4b
2 changed files with 29 additions and 17 deletions

View File

@@ -310,7 +310,7 @@ class SkyvernFrame:
)
finally:
if x is not None and y is not None:
await skyvern_frame.scroll_to_x_y(x, y)
await skyvern_frame.safe_scroll_to_x_y(x, y)
@staticmethod
@TraceManager.traced_async(ignore_inputs=["page"])
@@ -366,6 +366,12 @@ class SkyvernFrame:
js_script = "([x, y]) => scrollToXY(x, y)"
return await self.evaluate(frame=self.frame, expression=js_script, arg=[x, y])
async def safe_scroll_to_x_y(self, x: int, y: int) -> None:
try:
await self.scroll_to_x_y(x, y)
except Exception:
LOG.warning("Failed to scroll to x, y, ignore it", x=x, y=y, exc_info=True)
async def scroll_to_element_bottom(self, element: ElementHandle, page_by_page: bool = False) -> None:
js_script = "([element, page_by_page]) => scrollToElementBottom(element, page_by_page)"
return await self.evaluate(frame=self.frame, expression=js_script, arg=[element, page_by_page])