2014-09-02 47 views
2

我只是試驗DalekJS,我試圖讓一個Forloop運行...但終端給我一個...錯誤:錯誤:套接字掛斷...我只想知道DalekJS中循環的正確語法......任何示例都會很棒。DalekJS - ForLoop在測試

module.exports = { 
    'lets test some functions': function (test) { 
    test.open('https://instagram.com') 

     for(var i=0; i<5; i++){ 
     .wait(5000) 
     } 
    } 
}; 

每當我運行這個測試的終端返回錯誤...... 例如錯誤:錯誤:插座掛斷

+0

這似乎不是有效的JavaScript。看起來像'.wait(5000)'應該是'test.wait(5000)' – 2014-09-02 19:07:34

+0

錯誤代碼是否包含文本:'Exterminate'? ;) – xDaevax 2014-09-02 19:19:51

回答

3

我有這個問題 - 當我說「測試」內部行動爲我工作並在循環之後;即test.wait()和test.done()

+0

YUSSSSS !!!!!!!!!!!!!!! – 2014-09-02 19:18:21

+0

@MichaelYee你能發佈正確的解決方案看起來像誰的利益嗎? – 2014-09-02 19:18:45

0

可以使用execute method自定義調用JavaScript

module.exports = { 
    'lets test some functions': function (test) { 
    test.open('https://instagram.com') 
     .execute(function(){ 
      for(var i=0; i<5; i++){ 
       test.wait(5000); 
      } 
     }) 
     .done(); 
    } 
}; 
0

我終於得到這個作爲工作:

module.exports = { 
    'lets test some functions': function (test) { 
    test.open('https://instagram.com') 
      for(var i=0; i<5; i++){ 
       test.wait(5000); 
      } 
     test.done(); 
    } 
}; 

注意:不需要執行,但'測試'需要附加到.wait()和.done()