Get help with testing, discuss unit testing strategies etc.


Post by mima1974 »

Hi,

If I try to call a next step with a parameter via the "setTimeout()" function, then Siesta do not notice the delay time.
With the consequence that the next step will direktly executed after the prior step (without delay).

Here a Sample:

StartTest(function (t) {

    t.chain(function (next) {
        var cboTemplateSelection = t.getComboCmpByTestId('ttFrame-admin-campaigns-template-combo', false)
        // Click on combo to open popup-List
        t.click(cboTemplateSelection)
        setTimeout(next(cboTemplateSelection), 3000)   // <-- Wrong ... don't wait 3 secondes

    }, function (next, cbo) {
          console.log('cbo:')
          console.log(cbo) // OK
          // Click on element in popup-list
          t.clickOnComboDropDownEntry(cbo, t.harness.settings.N005_create_Campaign.nameOfReferenceCampaign)
          t.done()
      })
});

Greetings Micha

Post by mats »

You're executing it here:
setTimeout(next(cboTemplateSelection), 3000) 
You want:
setTimeout(function() { next(cboTemplateSelection) }, 3000);
But even that is messy and not using Siesta properly:
var cboTemplateSelection = t.getComboCmpByTestId('ttFrame-admin-campaigns-template-combo', false);

t.chain(
     { action : 'click', target : cboTemplateSelection },
     { waitFor : 3000 },  // Why an arbitrary wait?
     function (next) {
          // Click on element in popup-list
          t.clickOnComboDropDownEntry(cboTemplateSelection , t.harness.settings.N005_create_Campaign.nameOfReferenceCampaign)
      }
);

Post Reply