【发布时间】:2017-01-28 08:07:15
【问题描述】:
我正在尝试编写一个 Nightmare.js 测试,它在执行过程中的多个点断言/evaluate()。
it("should return to home page when quit button is pressed", function (done) {
var username = 'sinbad';
new Nightmare({ show: true })
.goto(url)
.type('#choosenickname', username)
.click('#write-btn')
.wait('div.game')
.evaluate(function () {
return document.querySelectorAll('#write-btn').length;
})
.then(function (result) {
// No 'write' buttons found
result.should.eql(0);
})
// Everything after this point doesn't work
.click('#quit-btn')
.wait('div.home')
.evaluate(function () {
return document.querySelectorAll('#write-btn').length;
})
.then(function (result) {
// After quitting, we should have a write button
result.should.eql(1);
done();
});
});
当我运行它时,我得到了
TypeError: (intermediate value).goto(...).type(...).click(...).wait(...).evaluate(...)
.then(...).click is not a function
【问题讨论】:
-
某位gitter指出了这一点,我需要测试一下:github.com/rosshinkley/nightmare-examples/blob/master/examples/…