Skip to content

CypressError: cy.screenshot() failed because it requires a DOM element. #75

@sprasad61

Description

@sprasad61

This was my test script

describe("First Test", ()=>{
    beforeEach(()=>{
        cy.visit('/');
    })
    it("should visit the home page", ()=>{
        cy.get('h1').matchImageSnapshot();
    })
})

On running the command npx cypress run, I was facing the following error

  1) First Test
       should visit the home page:
     CypressError: `cy.screenshot()` failed because it requires a DOM element.

The subject received was:

  > `null`

The previous command that ran was:

  > `cy.task()`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions