Nagamani Kumaresan
Nagamani Kumaresan

Reputation: 1

how to scroll the page in AngularJS application using Protractor

I need to scroll the page on AngularJS application using protractor

browser.executeScript('window.scrollTo(0,200);').then(function () {

The above code is not getting executed.

Upvotes: 0

Views: 92

Answers (3)

tyaga001
tyaga001

Reputation: 169

Try this one

  var scrolldown = by.css(' keep your class here');
    browser.controlFlow().execute(function() {
        browser.executeScript('arguments[0].scrollIntoView(true)', scrolldown.getWebElement());
    });

Upvotes: 0

M. Hudson
M. Hudson

Reputation: 899

What do you need to scroll to? The way I handle this is like so:

var lastElement = element.all(by.css('td')).last();
browser.actions().mouseMove(lastElement).perform();

Upvotes: 1

Sanja Paskova
Sanja Paskova

Reputation: 1110

You can use this library: https://www.npmjs.com/package/sg-protractor-tools

You can use the library's functions by referencing the sgpt object, e.g. for scrolling:

sgpt.scroll.scrollTo(...);

Upvotes: 0

Related Questions