2016-11-27 5 views
0

docsで表示されている例は、.then()の前に.end()を使用しています。このよう連鎖した後のNightmareJsインスタンスの終了方法

nightmare 
    .goto('http://yahoo.com') 
    .type('form[action*="/search"] [name=p]', 'github nightmare') 
    .click('form[action*="/search"] [type=submit]') 
    .wait('#main') 
    .evaluate(function() { 
    return document.querySelector('#main .searchCenterMiddle li a').href 
    }) 
    .end() 
    .then(function (result) { 
    console.log(result) 
    }) 
    .catch(function (error) { 
    console.error('Search failed:', error); 
    }); 

として はしかし、私は...のようにそれを行うには

... 
.then(function() {...}) 
.end() 

をしようとしているしかし、私は.ENDが存在しないというエラーを取得します。

私も以下を試しましたが、エラーは発生しませんが、悪夢がハングアップする原因になります。 Github issue discussion

nightmare.endパー

... 
.then(function() {...}) 
.then(function() { 
    nightmare.end() 
}); 

答えて

2

()チェーン.then()からを返さでなければならない、とだけで起動されません。

... 
.then(function() {...}) 
.then(function() { 
    return nightmare.end(); 
}) 
関連する問題