jeudi 30 août 2018

How to break out of a while loop and if statement?

I need to break out both the while loop and if statement when the the value inside the if statement is great than 0, in turn the code should then break from the while loop.

How can I achieve this?

My code is as follows:

it('x Accordion description should appear after 5 seconds upon being clicked', function(done) {
      //this.timeout(15000);
      //setTimeout(done, 6000);
      var i = 0;
      while (i < 15000) {
          browser.click('#accordion');
          //var timeoutText = browser.getText('#timeout').length;
          var timeoutText = browser.getText('#timeout').length;
          console.log(timeoutText);

            if (timeoutText > 0) {
                  browser.pause(5000);
                  console.log("Pass");
                  break;
                  i++;
            }
      }

Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire