primaryDeveloper
primaryDeveloper

Reputation: 91

How to use cypress, scrollTo in Ionic App?

For a test in Cypress I want to scroll down to the bottom of the page created with Ionic.

I have tried using scrollTo on the window:

cy.scrollTo('bottom')

But got an error: Timed out retrying after 4000ms: cy.scrollTo() failed because this element is not scrollable:<window>

Using scrollIntoView on the element itself, did not help either.

Also scrolling the main ionic container:

cy.get('ion-content').scrollTo('bottom')

resulted in the same error.

Has anybody an idea?

Upvotes: 1

Views: 845

Answers (2)

Lungio
Lungio

Reputation: 61

If you set the focus inside the ion-content for example by clicking any element inside it then you can use .scrollIntoView().

Upvotes: 1

primaryDeveloper
primaryDeveloper

Reputation: 91

Using the main div in shadow root inside the ion-content container did the trick for me:

cy.get('ion-content').shadow().find('main').scrollTo('bottom')

It seems to be the container which is actually scrollable

Upvotes: 5

Related Questions