Created
November 24, 2016 21:16
-
-
Save Tirael/0465a11c8d0fbac7757923ff71c23384 to your computer and use it in GitHub Desktop.
Nightmare.JS infinite scroll action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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