Scroll down to an element with protractor

This seems so late to answer you.. But anyways,

The following code helped me to remove the Element is not clickable error.

var elm = element.all(by.css('.your-css-class')).get(9);
browser.executeScript("arguments[0].scrollIntoView();", elm.getWebElement());

elm.click();

Basically this allows you scroll into your view..


The window.scrollTo(x,x) solution didn't work for me. Specially when testing against ripple emulator. I managed to make it work using scrollIntoView method.

var scrollToScript = 'document.getElementById("ELEMENT ID").scrollIntoView();';

browser.driver.executeScript(scrollToScript).then(function() {
  element(by.id('ELEMENT ID')).click();
  expect(...);
});

'use strict';

/**
 * Vertically scroll top-left corner of the given element (y-direction) into viewport.
 * @param scrollToElement element to be scrolled into visible area
 */
function scrollTo(scrollToElement) {
    var wd = browser.driver;
    return scrollToElement.getLocation().then(function (loc) {
        return wd.executeScript('window.scrollTo(0,arguments[0]);', loc.y);
    });
};

Usage:

scrollTo(element(by.css("div.someclass")));

Disclaimer: this code is from sg-protractor-tools's scroll.js.
Code is licensed under the MIT license.