How to simulate scrolling with Protractor?

Because Ionic uses it’s own way of scrolling, window.scrollTo( ) won’t work.

Is there some way to get access to $ionicScrollDelegate from my Protractor tests?

1 Like

I have the same question, any support for that?

Here is how i solved same issue

First, i disabled jsScrolling

beforeEach(function() {
  browser.addMockModule('IonicConfig', function() {
    angular.module('IonicConfig', []).config(function($ionicConfigProvider) {

Then, i use browser.executeScript("document.querySelector('ion-content').scrollTop = document.querySelector('ion-content').scrollHeight") to emulate scroll to the bottom

While writing a test for infinite scrolling I experienced the same issue.

I think jsScrolling is necessary for infinite scrolling (not entirely sure, haven’t tested it).

Anyway, I took a slightly less invasive approach;

browser.addMockModule('ionicScrollDelegate', () => {
  const run = ($ionicScrollDelegate) => {
    window.$ionicScrollDelegate = $ionicScrollDelegate;
  run.$inject = ['$ionicScrollDelegate'];
  angular.module('ionicScrollDelegate', []).run(run);

To check infinite scrolling loading more table rows I did the following;

browser.wait(protractor.ExpectedConditions.presenceOf($('.row20')), 10000);