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

Add more advanced screenshot clipping options #4440

Closed
mattbrailsford opened this issue Jun 12, 2019 · 6 comments · Fixed by #5078
Closed

Add more advanced screenshot clipping options #4440

mattbrailsford opened this issue Jun 12, 2019 · 6 comments · Fixed by #5078
Labels
topic: screenshots 📸 type: enhancement Requested enhancement of existing feature

Comments

@mattbrailsford
Copy link

mattbrailsford commented Jun 12, 2019

Current behavior:

When creating a screenshot you can pass an options object with a clip option which accepts an x, y, width and height setting defining the absolute position that you want the screenshot to be clipped to.

Desired behavior:

I’d like to see the clipping options be extended to support relative or calculated coordinates. For example, the following could define a screenshot the viewport dimensions but inset by 50px.

cy.screenshot({ capture: “viewport”, clip: { inset: 50 } });

Or when screenshotting an element, allow offsetting it’s coordinates to capture 20px of its surrounding area.

cy.get(#myId”).screenshot({ clip: { offset: 20 });

My use case for this is mostly to use cypress for automating documentation screenshots, but I’m sure it could have uses within the testing arena.

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Jun 17, 2019
@jennifer-shehane jennifer-shehane added type: enhancement Requested enhancement of existing feature topic: screenshots 📸 labels Jun 17, 2019
@sebinsua
Copy link
Contributor

sebinsua commented Aug 28, 2019

@mattbrailsford My colleague and I might try to implement this. We couldn't decide whether to have a padding option, or the inset/offset idea you put forth. Is there some prior art to the naming you recommended?

Edit: TestCafe does this very differently.

@NMinhNguyen
Copy link

An API like this might be good? puppeteer/puppeteer#1692 (comment)

sebinsua added a commit to sebinsua/cypress that referenced this issue Sep 3, 2019
sebinsua added a commit to sebinsua/cypress that referenced this issue Sep 3, 2019
sebinsua added a commit to sebinsua/cypress that referenced this issue Sep 3, 2019
sebinsua added a commit to sebinsua/cypress that referenced this issue Sep 3, 2019
sebinsua added a commit to sebinsua/cypress that referenced this issue Sep 3, 2019
sebinsua added a commit to sebinsua/cypress that referenced this issue Sep 3, 2019
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: ready for work The issue is reproducible and in scope labels Sep 3, 2019
@sebinsua
Copy link
Contributor

sebinsua commented Sep 3, 2019

We've raised a preliminary PR #5078.

/cc @mattbrailsford @jennifer-shehane

sebinsua added a commit to sebinsua/cypress that referenced this issue Sep 3, 2019
sebinsua added a commit to sebinsua/cypress that referenced this issue Sep 3, 2019
@mattbrailsford
Copy link
Author

mattbrailsford commented Sep 3, 2019

@sebinsua sorry I never replied to your question, but this looks great. I think basing it on padding is a good solution. Inset could technically be achieved via a negative padding value so sounds like two birds with one stone 👍

sebinsua added a commit to sebinsua/cypress that referenced this issue Sep 4, 2019
sebinsua added a commit to sebinsua/cypress that referenced this issue Sep 4, 2019
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Sep 20, 2019
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 22, 2019
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 22, 2019
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: needs review The PR code is done & tested, needs review labels Sep 24, 2019
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 25, 2019
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 25, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 26, 2019
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 26, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 26, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 26, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 26, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 26, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 26, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 26, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 27, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 27, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 27, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 27, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 27, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
NMinhNguyen added a commit to sebinsua/cypress that referenced this issue Sep 30, 2019
Closes cypress-io#4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Oct 1, 2019
jennifer-shehane pushed a commit that referenced this issue Oct 11, 2019
* Handle 0px tall elements with a better error message

Closes #5149

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>

* Add padding support to element#screenshot

Closes #4440

Co-authored-by: Minh Nguyen <[email protected]>
Co-authored-by: Jennifer Shehane <[email protected]>

* add e2e tests
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Oct 11, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 11, 2019

The code for this is done in cypress-io/cypress#5078, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2019

Released in 3.5.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: screenshots 📸 type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants