Verify scrolling to the bottom of a long page
Preconditions (1)
✅ Expected Result: The page scrolls smoothly to the bottom, and the footer element with id 'footer' is visible
describe('Scroll to bottom test', () => { it('should scroll to the bottom and verify footer visibility', () => { cy.visit('https://example.com/long-page'); cy.scrollTo('bottom'); cy.get('#footer').should('be.visible'); }); });
The test opens the long page URL using cy.visit(). Then it uses cy.scrollTo('bottom') to scroll the page to the bottom smoothly. After scrolling, it locates the footer element by its id #footer using cy.get(). Finally, it asserts that the footer is visible on the screen with .should('be.visible'). This confirms the scroll action worked as expected.
Now add data-driven testing to scroll to different positions: 'top', 'center', and 'bottom' and verify footer visibility only at 'bottom'
cy.scrollTo() in Cypress testing?cy.scrollTo() is used to scroll the page to a certain position.cy.scrollTo()?cy.scrollTo(0, 500);
cy.get('#footer').should('be.visible');
cy.scrollTo(0, 500) do before checking the footer visibility?cy.scrollTo(bottom);
cy.get('.menu').should('be.visible');
#submit is visible. Which of the following code snippets correctly achieves this?Pass the test and this pattern moves unknown