2017-10-05 1 views
1

Ich bekomme nicht wirklich albtraum, also ist es wahrscheinlich wirklich einfach.
Meine Frage ist, warum App auf Facebook URL festhängt und nicht zu Google geht?NightmareJs goto nach bewerten

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) 
    nightmare.goto('https://google.com') 
    }) 

Antwort

0

Die folgende Zeile gibt ein Versprechen zurück, Sie haben das Versprechen zuerst zu den Daten aufgelöst. Füge einfach eine then() in die Albtraumversprechen-Kette ein.

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

Hier ist der vollständige Code mit einer besseren Kette.

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") 
    }) 

Und hier ist das Ergebnis, Nightmare