Forum Discussion
chicks
14 years agoRegular Contributor
Are you using recorded tests? I solved this problem (using JavaScript scripting) by writing a waitUntil function. You pass it a function that evaluates as true false and a maximum time limit. It calls the function at 1 second intervals and then stops when it evaluates as true.
var WAIT_FOR_RETAILERS = 30; // allow up to 30 seconds for the retailers to show up in the drop down list....
// code where I need to wait.....
waitUntil(WAIT_FOR_RETAILERS, retailersInDDL);
.....
function waitUntil(maxTime, evaluation) {
//
evaluation is a function that should return true when it's ok to continue
// of false otherwise e.g. values are appearing in a drop down list...
for (var i=0; i < maxTime; i++) {
// Log.Message("waiting...." + i + " seconds");
if (evaluation() ) {
Log.Message( "Wait was " + i + " seconds" );
if (i> 2) {
Log.Warning ("Wait was greater than two seconds");
}
return;
}else {
delay(1000);
}
}
Log.Error("waited " + maxTime + " seconds without condition passing.");
}
function retailersInDDL() {
retailersInDDL() {
// evaluation condition for wait until...
if (signup_retailer().wItemCount !=0 ) {
return true;
}
else {
return false;
}
}
Regards, Curt Hicks