NightmareJS works great when I am running one evaluation, but as I interact with the page I need to do more evaluations as things pass. However using the docs I tried a simple sample of chaining evaluations and I get an error:
describe('test google search results', function() {
this.timeout(15000);
it('should find the nightmare github link first', function(done) {
var nightmare = Nightmare({show: true})
nightmare
.goto('http://google.com')
.wait(1000)
.type('form[action*="/search"] [name=q]', 'github nightmare')
.click('form[action*="/search"] [type=submit]')
.wait(1000)//.wait('#rcnt')
.evaluate(function () {
return document.querySelector('div.rc h3.r a').href
})
.then(function(link) {
console.log("TESTING 1");
expect(link).to.equal('https://github.com/segmentio/nightmare');
})
.wait()
.evaluate(function () {
return document.querySelector('div.rc h3.r a').href
})
.end()
.then(function(link) {
console.log("TESTING 2");
expect(link).to.equal('https://github.com/segmentio/nightmare');
done();
})
});
});
Error:
TypeError: nightmare.goto(...).wait(...).type(...).click(...).wait(...).evaluate(...).then(...).wait is not a function
In this case I added a wait before the next evaluation in case I needed to let the system wait for a complete but still it is not working.