简体   繁体   中英

Simulate timeout in Phantom JS

We are taking screenshots using PhantomJs, which works quite well for us. Now we face the challenge that some of the websites we take screenshots of have animations when the page loads. We can of course use a simple timeout of, let's say, 5 seconds, but we surely don't want to wait actual 5 seconds idling for each screenshot.

Is there a way to "simulate" a screenshot, ie to tell Phantom to internally fast forward 5 seconds while actually, from the outside, no time passes?

No, there is no way to fast forward the time 5 seconds.

As a workaround, you might want to take a screenshot every second and see if it changes with a timeout at 10 seconds for example. The comparison of the images can be done in various ways like actual byte by byte comparison or invocation of some image library that can actually compare the image data itself where you can set a match even when the images are only 99% equal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM