Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
2 years ago
Solved

Effective alternative to aqUtils.Delay(timeoutvalue);

Hi friends,

 

I have bdd javascripts that run on java based desktop application. The desktop is slow at many operations such as when it selects some value from the drop down, it takes time and the next line in the script executes. This is solved by using aqUtils.Delay(timeoutvalue); 

Example;

The below function in When statement has delay:

function (certificate) {
var jHeaderTable;

jHeaderTable = GetTableObject(); //this method returns object

jHeaderTable.Keys('^[End][Up]');

jHeaderTable.Keys("some input");

aqUtils.Delay(1000);
}

Now if the next function which is in Then statement executes without the delay above, the test fails. Reason could be the object takes time to be available etc.

I don't want to apply lots of Delay with hardcoded timeout. Is there any efficient way to do that. I read a page on waitnnn, waitxxx etc. but don't know if they can be applied in the above scenario. 

Also, if Macros can be used with waits ?

 

Thank you!

  • Hi,

     

    I read a page on waitnnn, waitxxx etc. but don't know if they can be applied in the above scenario. 

    Yes, this is the correct way: your test code should wait in a loop until either the required object appears and gets required state (enabled, populated with data, etc.) or timeout occurs.

     

1 Reply

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    I read a page on waitnnn, waitxxx etc. but don't know if they can be applied in the above scenario. 

    Yes, this is the correct way: your test code should wait in a loop until either the required object appears and gets required state (enabled, populated with data, etc.) or timeout occurs.