2

I'm just experimenting with DalekJS, and I'm trying to get a Forloop to run... but the terminal gives me a... ERROR: Error: socket hang up... I just want to know the proper syntax for loops in DalekJS... any example would be awesome.

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

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

whenever I run this test the terminal returns an Error... example ERROR: Error: socket hang up

3 Answers3

3

I had this problem - worked for me when I added "test" to actions inside and after the loop; i.e., test.wait() and test.done()

hildtfw
  • 46
  • 2
0

You can use the execute method to call custom 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();
   }
};
Juan Mendes
  • 80,964
  • 26
  • 138
  • 189
0

I finally got this to work as:

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();
   }
};

Note: no execute necessary, but 'test' needs to be appended to .wait() and .done()

AndyB
  • 31
  • 7