Created
November 24, 2016 16:15
-
-
Save Tirael/8b5707f7e188fcd6fb720d9d1ee27b0d to your computer and use it in GitHub Desktop.
Nightmarejs .click() on each element with delay between
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 nightmare = Nightmare({ show: true }); | |
nightmare | |
.goto('http://example.com/') | |
.click('.buttonOpenModal') | |
.wait('div.Buttons') | |
.evaluate(function () { | |
var interval = setInterval(function () { | |
var btn = document.querySelectorAll('div.Buttons'); | |
if (undefined == btn || 0 == btn.length) { | |
clearInterval(interval); | |
} | |
else { | |
btn[0].click(); | |
} | |
}, 5000); | |
}) | |
.end() | |
.then(function (result) { | |
console.log(result) | |
}) | |
.catch(function (error) { | |
console.error('Search failed:', error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment