NightmareJSは1つの評価を実行しているときに効果的ですが、私がページとやり取りするときには、物事が進むにつれて評価を増やす必要があります。しかし、私は、連鎖評価の簡単なサンプルを試してみましたが、私はエラーを取得するドキュメントを使用して: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(...)(...)を待つタイプ(...)。(...)。(...)。(...)。(...)をクリックしてください。システムが完全な状態を待つ必要がある場合に備えて、次の評価の前に、まだ動作していません。
もう少しテストしていただき、ありがとうございました。チャイから期待するのではなく、読み込み中であることが判明するまで、まだいくつかのエラーが出ていました。 –
これをより詳細に見てみると、100個のネストされたテストを書く必要があるときに管理するのが難しいように思えます。ネストされたエバールを書くためにはよりエレガントですか?私は約束を払うことを考えていたが、約束を入れなければならない場合は、うまくいかないかもしれない。 –
もう少しテストした後、私は次の解決策を考え出しました:http://stackoverflow.com/questions/40297378/nightmarejs-multiple-reports-from-same-test/40298901#40298901今必要です。 –