Repository navigation
feat: introduce option to specify delay before any screenshot is made - #820
Conversation
|
Is there any feedback regarding this feature? |
| } | ||
|
|
||
| captureViewportImage(page) { | ||
| return this._camera.captureViewportImage(page); |
There was a problem hiding this comment.
browser.captureViewportImage will be called
- on calibration
- on any error
- few times during capturing if
compositeImageistrue
So this is not the good place to insert the delay.
The best place probably would be the CaptureSession.capture (which will be preformed in worker) or even CaptureSession.prepareScreenshot (which will be performed in master process)
There was a problem hiding this comment.
Actually it is intended that the delay is executed multiple times when compositeImage is true. That is why I added it in this position.
E.g. we have a scroll to top button which is faded in when the user scrolls down. As the browser is scrolled down when compositeImage is true, the delay needs to be executed after scrolling to ensure that the animation has finished. As far as I can see adding them to CaptureSession.capture or CaptureSession.prepareScreenshot will only delay once before creating the composite screenshot and thus create screenshots with an inconsistently faded in scroll to top button.
| parseEnv: Number, | ||
| parseCli: Number, | ||
| validate: (value) => { | ||
| is('number')(value); |
There was a problem hiding this comment.
you can use assertNonNegative(value, 'screenshotDelay') instead of those checks
f27aea3 to
d41bab6
Compare
|
@selaux In our projects all animations are disabled in tests. What do you think about this? You can inject some script into test page or execute some js |
|
I'd suggest you to try to disable animation in your test. But if by some reason you can't do this, then we will release this feature in one of the future versions |
|
We though about just disabling animations, but depending on how animations are implemented this can get arbitrarily complex (e.g. for javascript based animations). I don't remember exactly why, but we couldn't achieve it with reasonable effort. |
|
|
||
| :warning: Option does not work in Opera@12.16. | ||
|
|
||
| * `screenshotDelay` — allows to specify a delay before making any screenshot (default: `0`). |
There was a problem hiding this comment.
write, please, that delay is in milliseconds
d41bab6 to
ec52a5e
Compare
|
Thanks for the contribution. It would be released in the next gemini version |
|
Nice. Thanks 🙂 |
|
We have custom fonts loaded from Google Fonts and it seems that latest Chrome now (always?) renders the page without fonts and then re-renders it. The delay is like 70-100ms, but it's enough to make tests unstable, with this feature in place adding |
Rationale: If your page contains some animations, it becomes annoying to use
.waitbefore each capture to wait for the animation to finish. Additionally having animations that are triggered by scrolling currently result in inconsistent dumps when the browser scrolls the page.Solution: This PR introduces a new option
screenshotDelaywhich defines the time that we wait before doing any screenshot. This allows for any animation to finish before the screenshot is taken, assumedscreenshotDelayis bigger than the longest animation time.