fix wait for animation end (#3201)
This commit is contained in:
@@ -2642,6 +2642,28 @@ async function getIncrementElements(wait_until_finished = true) {
|
||||
return [Array.from(idToElement.values()), cleanedTreeList];
|
||||
}
|
||||
|
||||
function isAnimationFinished() {
|
||||
const animations = document.getAnimations({ subtree: true });
|
||||
const unfinishedAnimations = animations.filter(
|
||||
(a) => a.playState !== "finished",
|
||||
);
|
||||
if (!unfinishedAnimations || unfinishedAnimations.length == 0) {
|
||||
return true;
|
||||
}
|
||||
const unfinishedAnimationsWithoutBlocked = unfinishedAnimations.filter(
|
||||
(a) => {
|
||||
const element = a.effect?.target;
|
||||
if (!element) {
|
||||
_jsConsoleLog("Unfinished animation without element:", a);
|
||||
return false;
|
||||
}
|
||||
const result = getBlockElementUniqueID(element);
|
||||
return !result[1];
|
||||
},
|
||||
);
|
||||
return unfinishedAnimationsWithoutBlocked.length === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
// How to run the code:
|
||||
|
||||
@@ -557,7 +557,8 @@ async def scrape_web_unsafe(
|
||||
|
||||
try:
|
||||
await page.wait_for_load_state("load", timeout=3000)
|
||||
await SkyvernFrame.wait_for_animation_end(page)
|
||||
skyvern_frame = await SkyvernFrame.create_instance(page)
|
||||
await skyvern_frame.safe_wait_for_animation_end()
|
||||
except Exception:
|
||||
LOG.warning("Failed to wait for load state, will continue scraping", exc_info=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user