2017-10-05 7 views
1

私は本当にナイトメアを取得しないので、おそらく本当に簡単です。
私の質問は、アプリがFacebookのURLに固執し、Googleには行かない理由です。評価の後にNightmareJs goto

​​3210

答えて

0

次の行は、約束を返します。約束を最初に解決しました。ナイトメアの約束にthen()を追加するだけです。

nightmare 
    .goto('https://google.com') 
    .then(function(){ 
     console.log("I'm done") 
    }) 

ここで、より良いチェーンを持つ完全なコードです。

var Nightmare = require('nightmare'); 
var nightmare = Nightmare({ show: true }); 

nightmare 
    .goto('https://facebook.com') 
    .evaluate(function() { 
     return document.title; 
    } 
    ) 
    .then(function(result){ 
    console.log(result) 
    return nightmare.goto('https://google.com') 
    }) 
    .then(function(){ 
    console.log("I am on google") 
    }) 

そしてここでの結果である、 Nightmare