Test for scrolling
angularjs, protractor
Solution
You can use javascript's window.pageYOffset for this. Here's how I've done it in one of my own test case:
browser.driver.sleep(2000);
browser.executeScript('return window.pageYOffset;').then(function(pos) {
expect(pos).to.be.at.most(100);
});
Where 100 is my expected position.
Note: I'm using mocha and chai instead of jasmine. So, just change the last line accordingly. Also I'm waiting 2 seconds for my scrolling to complete.
Problem
In my angular application, I have a page that has nav links on the side, that, when clicked, scrolls the page down to a matching element. How do I write e2e test for this in protractor? Is there something like "Grab the first visible h1" or something like that?