2014-09-02 48 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()