Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take screenshots using Chrome DevTools Protocol #5899

Closed
jennifer-shehane opened this issue Dec 6, 2019 · 6 comments
Closed

Take screenshots using Chrome DevTools Protocol #5899

jennifer-shehane opened this issue Dec 6, 2019 · 6 comments
Labels
topic: screenshots 📸 type: enhancement Requested enhancement of existing feature

Comments

@jennifer-shehane
Copy link
Member

Current behavior:

Cypress screenshot algorithm is complicated and has introduced several challenges.

Desired behavior:

Now that #4628 is merged, Cypress has access to Chrome's Debugger Protocol which could be used to take screenshots.

Page.captureScreenshot docs: https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-captureScreenshot

Challenges

  • This would only be usable in Chrome browser and not extensible to other browsers, so we would have to maintain the other screenshot algorithm anyway unless there are comparable substitutions for other browsers.

Versions

3.7.0

@cypress-bot cypress-bot bot added the stage: proposal 💡 No work has been done of this issue label Dec 6, 2019
@jennifer-shehane jennifer-shehane added stage: proposal 💡 No work has been done of this issue type: enhancement Requested enhancement of existing feature and removed stage: proposal 💡 No work has been done of this issue labels Dec 6, 2019
@mikila85
Copy link

Fix this already!!!

@flotwig
Copy link
Contributor

flotwig commented Dec 12, 2019

@mikila85 You are welcome to open a pull request if you need this quickly. You will want to start with the handler for take:screenshot in cdp_automation.ts. Let us know if you have any questions.

@ThomasGHenry
Copy link

Hey, folks. What's the lowest overhead alternative to this in the meantime? Would anyone recommend a workaround? Thanks

@flotwig
Copy link
Contributor

flotwig commented Jan 28, 2020

@ThomasGHenry Does cy.screenshot() not work for you? This issue is about changing the internal implementation of screenshots, so there's not really a workaround for it.

@ThomasGHenry
Copy link

Thanks, @flotwig.

It does not. I'm experiencing this #5876

I'm wondering if anyone recommends a 3rd party option that plays nicely with cypress in the meantime. Cloud-based solutions like Percy and Applitools aren't ideal. Anything else I've found so far uses cy.screenshot() under the covers. Thanks!

@flotwig
Copy link
Contributor

flotwig commented Jan 29, 2020

@ThomasGHenry Might have to wait to use --headless until #5876 is fixed, I'm not sure if there are any 3rd-party screenshot tools for Cypress.


With regard to this issue - @jennifer-shehane I think we actually are already taking screenshots using CDP in Chrome and Electron since 3.5.0:

case 'take:screenshot':
return sendDebuggerCommandFn('Page.captureScreenshot')
.catch((err) => {
throw new Error(`The browser responded with an error when Cypress attempted to take a screenshot.\n\nDetails:\n${err.message}`)
})
.then(({ data }) => {
return `data:image/png;base64,${data}`
})

So closing this... oops 😅

@flotwig flotwig closed this as completed Jan 29, 2020
@jennifer-shehane jennifer-shehane removed the stage: proposal 💡 No work has been done of this issue label Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: screenshots 📸 type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

4 participants