question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal - cy.screenshot enhancements

See original GitHub issue

Make cy.screenshot() more useful to go down the path towards screenshot diffing.

Let’s create a new set of API’s to make it easier to take a picture of the AUT (application under test) without involving the Cypress UI.

To make this happen, we’ll also need to give the user the option to remove the artificial “scaling” Cypress applies, and we’ll need to black out all of the excess areas.

Bonus points for also going down the route of slicing out the “blacked out” areas of the picture so the resulting screenshot has no excess - and is insulated from resolution differences.

This also leads us towards being able to take pictures of just dom elements instead of the whole window.

Cypress.Screenshot.defaults({
  capture: 'commands | app | both', // default 'commands'
  waitForCommandSynchronization: true, // when taking a picture of the commands, wait until they are synchronized
  scaleAppCaptures: false, // when taking a picture of the app, remove the scaling
  disableTimersAndAnimations: true, // prevent app animations and timers from firing
  screenshotOnRunFailure: true, // config.screenshotOnRunFailure
  blackout: ['selectors'], // whatever matches, we'll blackout their box model
  onScreenshot: ($dom) => {

  },
})

To disable animations - we need to keep references for setTimeout, setInterval, requestAnimationFrame during the initial phase of event binding to the window - and then prevent callbacks from firing until the screenshot has been taken.

onScreenshot would yield you the $elements that are being screenshotted - enabling the user to synchronously perform changes on it (like changing dynamic content).

blackout allows the user to easily pick selectors which we’d use to blackout their box model. This would utilize the logic for layering hitboxes (except layer only a blacked out piece)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

13reactions
brian-manncommented, May 30, 2018

Released in 3.0.0.

3reactions
brian-manncommented, Mar 6, 2018

To disable CSS animations insert this <style> into the document:

*, *:before, *:after {
  transition-property: none !important;
  transform: none !important;
  animation: none !important;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

screenshot - Cypress Documentation
Screenshots in CI​​ You can see screenshots taken during a CI run in Cypress Cloud without any extra work. Alternatively, to see screenshots...
Read more >
Screenshot Testing with Selenium, Cypress and Playwright
There is room for enhancement. We can move from capturing and saving screenshots into automated visual testing with Applitools. Visual testing ...
Read more >
Cypress.io + Percy = End-to-end functional and visual testing ...
Write smaller, more effective tests; Delete/refactor CSS, layouts, and designs without fear; Make dependency upgrades safely; Test visualizations easily; Reach ...
Read more >
ISO New England
ISO-NE rolls out enhancements to report on 21-day energy supply forecast ... ISO-NE releases report on strategic plan for fulfilling three critical roles, ......
Read more >
Bug listing with status CONFIRMED as at 2022/12/26 10:46:31
... Bug:80148 - "[PATCH] Add last successful snapshot date support to emerge-webrsync" status:CONFIRMED resolution: severity:enhancement ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found