Test Overview
This test opens a webpage and takes a full-page screenshot to verify the entire page is captured correctly.
This test opens a webpage and takes a full-page screenshot to verify the entire page is captured correctly.
describe('Full-page Screenshot Test', () => { it('should capture a full-page screenshot', () => { cy.visit('https://example.cypress.io') cy.screenshot({ capture: 'fullPage' }) }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initialized, no browser opened yet | — | PASS |
| 2 | Browser opens | Browser window opens ready for testing | — | PASS |
| 3 | Navigates to 'https://example.cypress.io' | Page loads fully with visible content | Page URL is correct and page is loaded | PASS |
| 4 | Takes a full-page screenshot using cy.screenshot({ capture: 'fullPage' }) | Screenshot captures entire scrollable page content | Screenshot file is created and saved | PASS |
| 5 | Test ends | Screenshot saved, browser ready to close | — | PASS |
cy.screenshot({ capture: 'fullPage' }) do in Cypress testing?capture option in cy.screenshot()capture option controls what part of the page is captured. Setting it to 'fullPage' means the entire page, not just the visible viewport.cy.screenshot() captures only the visible part. 'fullPage' extends this to the whole page including scrollable areas.cy.screenshot() command accepts an options object where capture: 'fullPage' is the correct way to specify full-page capture.cy.fullPageScreenshot(), or trying to chain .capture('fullPage') are not valid Cypress syntax for full-page screenshots.cy.visit('https://example.com')
cy.screenshot({ capture: 'fullPage' })cy.screenshot() runs immediately after cy.visit(), the page might still be loading.cy.visit('https://example.com')
cy.screenshot({ capture: 'fullpage' })cy.get('#dynamic-section').should('be.visible') waits until the dynamic section is visible, ensuring content is loaded..then(() => cy.screenshot({ capture: 'fullPage' })) ensures the screenshot runs only after the wait condition passes.Pass the test and this pattern moves unknown