Cypress: Element not scrollable

Created on 22 Aug 2019  路  1Comment  路  Source: cypress-io/cypress

Current behavior:

We're trying to scroll down a page in order to trigger lazy-loading of content. This does not seem to work. While debugging, I found that scrolling on an arbitrary web page is also not possible:

cy.scrollTo("bottom") throws an error:

CypressError: Timed out retrying: cy.scrollTo() failed because this element is not scrollable:

Desired behavior:

The selected element is scrolled

Steps to reproduce: (app code and test code)

Tried this on 3.4.1 and using https://wikipedia.org as baseUrl in cypress.json

it('scroll', () => {
    cy.visit('https://www.wikipedia.org');
    cy.get('body').scrollTo('bottom', {
            duration: 10000,
            easing: 'swing',
        });
});

image

Versions

Mac OS 10.14.6 (18G87)
Cypress 3.4.1
Electron

Most helpful comment

The code below works. Why do you need to scroll the body? The body of wikipedia is not the actual element that is scrolling when a user scrolls, it scrolls the window, so that's why it's throwing.

  it('scrolls', () => {
    cy.visit('https://www.wikipedia.org')
    cy.scrollTo('bottom', {
      duration: 10000,
      easing: 'swing',
    })
  })

This works too

cy.window().scrollTo('bottom')

>All comments

The code below works. Why do you need to scroll the body? The body of wikipedia is not the actual element that is scrolling when a user scrolls, it scrolls the window, so that's why it's throwing.

  it('scrolls', () => {
    cy.visit('https://www.wikipedia.org')
    cy.scrollTo('bottom', {
      duration: 10000,
      easing: 'swing',
    })
  })

This works too

cy.window().scrollTo('bottom')
Was this page helpful?
0 / 5 - 0 ratings