jeudi 7 novembre 2019

Nightwatch loop not performing as expected

I need some help with loops in Nightwatch testing.

  for(var i = 1; i < 10; i++) {

    browser.click(productsSelector)
    browser.click('#\\31 0322 > td.sorting_1 > a')
    browser.click('#myTab > li:nth-child(3) > a')
    browser.pause(1000)
    browser.setValue('#example > thead > tr.table-filters > td:nth-child(1) > input[type=text]', '85/2018')
    browser.pause(1000)


    browser.perform(function () {
      console.log('loop number = ' + i); 
    });

    browser.perform(function() {
        browser
        .pause(1000)
        .click(movingsSelector)
        .pause(1000)
        .click('.fa.fa-plus-square')
        .click('#moving_direction')
        .pause(4000)
       if (i < 10) {
         browser
         .click('option[value="from_main"]');}

       })
   }  

When I perform this test for loop is executed first till reaching i =10 an den goes through every line in block instead of reapiting all commands al over again 10 times as it should be. I this case it should go through the block without performing if statment til the 10th time for loop goes... any ideas? this are basic for and if loops but it doesn`t perform as it should

Aucun commentaire:

Enregistrer un commentaire