Ask a Question

Effective alternative to aqUtils.Delay(timeoutvalue);

SOLVED
TestQA1
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
Community Hero

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 Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: