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

cy.within followed by cy.screenshot capture runner does not capture runner #14253

Closed
bahmutov opened this issue Dec 21, 2020 · 4 comments · Fixed by #14264
Closed

cy.within followed by cy.screenshot capture runner does not capture runner #14253

bahmutov opened this issue Dec 21, 2020 · 4 comments · Fixed by #14264
Assignees
Labels
topic: screenshots 📸 type: unexpected behavior User expected result, but got another

Comments

@bahmutov
Copy link
Contributor

Cypress v6.1.0

The following test

describe('page', () => {
  it('works', () => {
    cy.visit('https://example.cypress.io')
    cy.get('.banner').within(() => {
      // should capture the entire test runner
      cy.screenshot('hello-world', {
        capture: 'runner'
      })
    })
  })
})

I expect the screenshot to be of the entire runner, like this

Screen Shot 2020-12-20 at 10 51 19 PM

But it takes only the .banner

hello-world

The devtools console shows the subject of the within affects the screenshot command, ignoring capture: runner option

Screen Shot 2020-12-20 at 10 52 51 PM

Desired result

when using capture: runner we should ignore the subject instead

@bahmutov
Copy link
Contributor Author

Workaround is to set the subject back to the entire document (then there is no subject)

cy.get('.banner').within(() => {
  // should capture the entire test runner
  cy.document().within(() => {
    cy.screenshot('hello-world', {
      capture: 'runner'
    })
  })
})

@jennifer-shehane
Copy link
Member

I thought this might have been caused by a recent regression with the within changes, but this has been an issue since 3.8.1 at least.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 28, 2020

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

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Dec 28, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 4, 2021

Released in 6.2.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.2.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jan 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: screenshots 📸 type: unexpected behavior User expected result, but got another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants