2013-08-13 6 views
29

में टाइमआउट कैसे बढ़ाएं मैं waitFor() का उपयोग कर रहा हूं। के रूप में नीचे दिए गए कोड:कैस्परजेएस

casper.waitFor(function check() { 
    return this.evaluate(function() { 
     return this.evaluate(someFunction, 'variable 1','variable 2','variable 3') === 'yes'; 
    }); 
}, function then() { 
    console.log('Done'); 
}); 

Am कंसोल आउटपुट के रूप में यह हो रही

Wait timeout of 5000ms expired, exiting. 

मैं टाइमआउट कैसे बढ़ा सकते हैं?

संपादित करें: मैं

casper.waitFor(function check() { 
     return this.evaluate(function() { 
      return this.evaluate(someFunction, 'variable 1','variable 2','variable 3') === 'yes'; 
     }); 
    }, function then() { 
     console.log('Done'); 
    },10000); 

यह मुझे निम्न त्रुटि दे रही है करने के लिए कोड बदल गए हैं:

CasperError: Invalid timeout function, exiting. 
    C:/filename:1720 in _check 

उत्तर

27

के रूप में कहा here,

हस्ताक्षर

waitFor(Function testFx[, Function then, Function onTimeout, Number timeout]) 
है

तो, टाइमआउट निर्दिष्ट करने के लिए एक अतिरिक्त तर्क है।

casper.waitFor(function check() { 
    //... 
    }); 
}, function then() { 
    //... 
}, function timeout() { 
//... 
}, TIMEOUT_IN_MS); 
+5

आप टाइमआउट बढ़ाने के लिए एक विकल्प भी सेट कर सकते हैं। यह सभी समय के कार्यों के लिए डिफ़ॉल्ट होगा। निम्न लिंक देखें: [लिंक] (http://docs.casperjs.org/en/latest/modules/casper.html#timeout) – Ryguy

+0

कृपया संपादित करें देखें। मैंने कोड अपडेट किया है लेकिन संपादन – user2129794

+1

हां में दिखाए गए त्रुटि को प्राप्त कर रहा है, वास्तव में तीसरा तर्क टाइमआउट कॉलबैक पर है। टाइमआउट मान चौथा है। – Cybermaxs

53

उपयोग है कि हर प्रतीक्षा के समय समाप्त() फ़ंक्शन को बढ़ाने के लिए: casper.options.waitTimeout = 20000; (20sec)

+0

यह मान waitFor() के आदेश के लिए उपयोग किया जाएगा और सभी कॉमन्स @ फ़ैंच में भी प्रतीक्षा करें()? – gumuruh

+1

@ गुमुरुह: हाँ;) http://docs.casperjs.org/en/latest/modules/casper.html#waittimeout 'प्रतीक्षा प्रतीक्षा समय समाप्ति, प्रतीक्षा * परिवार के कार्यों के लिए। – Fanch

1

आप जबकि डिफ़ॉल्ट त्रुटि संदेश छोड़ने टाइमआउट को बढ़ाने के लिए चाहते हैं, तीसरा तर्क और की संख्या के रूप में पारित null मिलीसेकंड चौथे तर्क के रूप में प्रतीक्षा करने के लिए:

casper.waitFor(function check() { 
    return this.evaluate(function() { 
     return this.evaluate(someFunction, 'variable 1','variable 2','variable 3') === 'yes'; 
    }); 
}, function then() { 
    console.log('Done'); 
}, null, 10000); 
संबंधित मुद्दे