8000 feat: introduce option to specify delay before any screenshot is made by selaux · Pull Request #820 · gemini-testing/gemini · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

feat: introduce option to specify delay before any screenshot is made - #820

Merged
j0tunn merged 1 commit into
gemini-testing:masterfrom
selaux:delay-screenshots-for-animations
Jan 19, 2018
Merged

j0tunn merged 1 commit into
gemini-testing:masterfrom
selaux:delay-screenshots-for-animations

Conversation

@selaux
@selaux selaux commented Oct 6, 2017
Copy link
Copy Markdown
Contributor

Rationale: If your page contains some animations, it becomes annoying to use .wait before 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 screenshotDelay which defines the time that we wait before doing any screenshot. This allows for any animation to finish before the screenshot is taken, assumed screenshotDelay is bigger than the longest animation time.

@lo1tuma
lo1tuma commented Jan 10, 2018
Copy link
Copy Markdown
Contributor

Is there any feedback regarding this feature?

Comment thread lib/browser/browser.js
}

captureViewportImage(page) {
return this._camera.captureViewportImage(page);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

browser.captureViewportImage will be called

  • on calibration
  • on any error
  • few times during capturing if compositeImage is true

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)

@selaux selaux Jan 11, 2018 •
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@j0tunn
j0tunn requested a review from sipayRT January 10, 2018 11:35
Comment thread lib/config/browser-options.js Outdated
parseEnv: Number,
parseCli: Number,
validate: (value) => {
is('number')(value);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use assertNonNegative(value, 'screenshotDelay') instead of those checks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@selaux
selaux force-pushed the delay-screenshots-for-animations branch from f27aea3 to d41bab6 Compare January 11, 2018 17:05
@j0tunn
j0tunn commented Jan 15, 2018 •
Copy link
Copy Markdown
Contributor

@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

@j0tunn
j0tunn commented Jan 18, 2018
Copy link
Copy Markdown
Contributor

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

@selaux
selaux commented Jan 18, 2018
Copy link
Copy Markdown
Contributor Author

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.

Comment thread doc/config.md Outdated

:warning: Option does not work in Opera@12.16.

* `screenshotDelay` — allows to specify a delay before making any screenshot (default: `0`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write, please, that delay is in milliseconds

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@selaux
selaux force-pushed the delay-screenshots-for-animations branch from d41bab6 to ec52a5e Compare January 19, 2018 14:55
@j0tunn
j0tunn merged commit 082442a into gemini-testing:master Jan 19, 2018
@j0tunn
j0tunn commented Jan 19, 2018
Copy link
Copy Markdown
Contributor

Thanks for the contribution. It would be released in the next gemini version

@selaux
selaux commented Jan 20, 2018
Copy link
Copy Markdown
Contributor Author

Nice. Thanks 🙂

@artemyarulin
Copy link
Copy Markdown

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 screenshotDelay: 100 solves it. Alhtough I think Gemeni should have wait to all resource loaded first, hm.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

0