【发布时间】:2016-10-27 18:53:41
【问题描述】:
NightmareJS 在我运行一次评估时效果很好,但是当我与页面交互时,我需要在事情通过时进行更多评估。但是,使用文档我尝试了一个简单的链接评估示例,但出现错误:
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();
})
});
});
错误:
TypeError: nightmare.goto(...).wait(...).type(...).click(...).wait(...).evaluate(...).then (...).wait 不是函数
在这种情况下,我在下一次评估之前添加了一个等待,以防我需要让系统等待完成,但它仍然无法正常工作。
【问题讨论】:
标签: javascript mocha.js chai nightmare