I usually use the following command:
browser.driver.executeScript('window.scrollTo(0,1600);');
However, this command is no longer working.
No errors are showing in the console, making it difficult to troubleshoot.
Interestingly, the same script works for another test case but I cannot identify any differences between them.
As a solution, I attempted to use scrollIntoView which resulted in an infinite loop.
Full test case:
describe('My business page ', function() {
var EC = protractor.ExpectedConditions;
var loginBox = element(by.css("div.info-box.client-login.ng-scope"));
var centerElm = $$(("div.action-extra-content.wysiwyg-content.ng-binding.layout-column")).first();
var scrollIntoView = function (element) {
arguments[0].scrollIntoView();
};
beforeEach(function() {
browser.ignoreSynchronization = true;
});
afterEach(function() {
browser.ignoreSynchronization = false;
});
it('Main page - Top', function() {
browser.get('https://live.vcita.com/site/bungee');
browser.wait(EC.visibilityOf(loginBox), 30000);
browser.driver.sleep(5000);
});
it('Main page - Center', function() {
browser.executeScript(scrollIntoView, centerElm);
console.log("Scroll me!!!")
browser.driver.wait(EC.elementToBeClickable(centerElm),30000);
browser.driver.sleep(2000);
});
});
Error:
RangeError: Maximum call stack size exceeded
Stacktrace:
RangeError: Maximum call stack size exceeded
at Function.childCtor.base (C:\automation\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:2163:38)
at promise.Callback_.goog.defineClass.constructor (C:\automation\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:2431:23)
at new wrappedCtr (C:\automation\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:2366:26)
...