Skip to content

Instantly share code, notes, and snippets.

@Tirael
Created November 24, 2016 21:16
Show Gist options
  • Save Tirael/0465a11c8d0fbac7757923ff71c23384 to your computer and use it in GitHub Desktop.
Save Tirael/0465a11c8d0fbac7757923ff71c23384 to your computer and use it in GitHub Desktop.
Nightmare.JS infinite scroll action
var Nightmare = require('nightmare');
var vo = require('vo');
var nightmare = Nightmare({
show: true
});
var run = function * () {
yield nightmare.goto('http://scrollmagic.io/examples/advanced/infinite_scrolling.html');
var previousHeight, currentHeight=0;
while(previousHeight !== currentHeight) {
previousHeight = currentHeight;
var currentHeight = yield nightmare.evaluate(function() {
return document.body.scrollHeight;
});
yield nightmare.scrollTo(currentHeight, 0)
.wait(3000);
}
yield nightmare.end();
};
vo(run)(function(err) {
console.dir(err);
console.log('done');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment