I have an button on my page that is visible when the user scrolls down. Because of this, protractor tests give me an error:
UnknownError: unknown erro
In case anyone else is having troubles like I was:
I was trying to scroll to the bottom of the page to load my next set of data in an infinite scroll scenario. I tried different variations of window.scrollTo as well as arguments[0].click() with no success.
Finally I realized, to get the page to scroll, I had to bring focus to the "window" by clicking on any element within the window. Then window.scrollTo(0, document.body.scrollHeight) worked liked a charm!
example code:
element(by.className('')).click();
browser.executeScript('window.scrollTo(0,document.body.scrollHeight)').then(function(){
//whatever you need to check for here
});