Ask a Question

Effective alternative to aqUtils.Delay(timeoutvalue);

SOLVED
TestQA1
Frequent Contributor

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!

1 REPLY 1
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.

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
cancel
Showing results for 
Search instead for 
Did you mean: