Forum Discussion

anatar02's avatar
anatar02
Contributor
13 years ago

How do I wait for specified text?

Hello all, 



How do I wait for specified text to get loaded
into the desktop application and that does not have any properties rather than
text... Could you please help me to wait my script until the expected text to
load. 
  • I was using the WaitProperty method but its waiting even throw the specified text is presented in the panel !





    Aliases["Console"]["MainForm"]["top_Panel"]["WaitProperty"]("StatusBar|Change User",true,20000) 

    and also tried 

    Aliases["Console"]["MainForm"]["top_Panel"]["WaitProperty"]("StatusBar|Change User","StatusBar|Change User",20000) 



    Please advice me on the same...
  • chicks's avatar
    chicks
    Regular 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