Forum Discussion

m_essaid's avatar
m_essaid
Valued Contributor
11 years ago

Waiting for a window / "the object does not exist"

Hello,

I have a software that makes batchs that could be from 10 seconds long to several minutes.

I put a property checkpoint right after this batch.

The problem is that i have, when running the test, the message "object does not exist". The object is a window with an "ok" button that indicate the end of the batch.

So I can't put a specific timeout, the waiting time could be changing.



How could I make Test Complete wait for a specific object to exists ?



Thank you very much
  • Hi Mehdi,



    For such situations, we prefer using WaitAliasChild because:


    1. - the waiting time is a maximum so if the object appears earlier it will be acknowledged,


    2. - if the object is not found at max time, no error is raised




    Please checkout WaitAliasChild



    Sincerely
  • jorgesimoes1983's avatar
    jorgesimoes1983
    Regular Contributor
    I use this function, it waits for a property (objectidentifier, contenttext..) value until a time value



    function waitForProperty(propriedade, text, maxTime)

    {

      var p, page;

      var time_limit=0;

     

      do

      {

        aqUtils.Delay(10);

        time_limit += 100;

        Indicator.PushText(time_limit);

            

        if(time_limit>maxTime) // 1000

        {

          Log.Warning("[waitForProperty] Time exceeded");

          Log.Picture(Sys.Desktop.Picture(), "[+] SCREENSHOT");

          return;

        }

            

        page = Sys.Browser("iexplore").Page("http://*yoururl.com*").NativeWebObject.Find(property,text);

        

        Indicator.PopText();

      }

      while (! page.Exists)

     

      Log.Message("[waitForProperty] "+ text);

    }

  • chrisb's avatar
    chrisb
    Regular Contributor
    Assuming you know a property of the Window that doesn't change each time you run the test you could use the WaitWindow method (http://support.smartbear.com/viewarticle/56463/)



    If the properties of the window change each time you run the test you could still do the above with wildcards or if all else fails search for the object in a loop and exit the loop after n number of tries. 

  • simon_glet's avatar
    simon_glet
    Regular Contributor
    Hi Mehdi,



    For such situations, we prefer using WaitAliasChild because:


    1. - the waiting time is a maximum so if the object appears earlier it will be acknowledged,


    2. - if the object is not found at max time, no error is raised




    Please checkout WaitAliasChild



    Sincerely
  • m_essaid's avatar
    m_essaid
    Valued Contributor
    Thank you Chris and Simon, it helped a lot,



    I tried bothWaitWindow andWaitAliasChild, they worked quite fine.



    Example of WaitWindow :



    {------------------------------------------------------------------------------}




    procedure AttenteFenetre;


    var


    p, w;


    begin


    p := Sys.Process('MyProgram');


    w := p.WaitWindow('TFormMyForm', '*', -1, 100000);


    if w.Exists then   


    begin


      if aqObject.CheckProperty(Aliases.MyProgram.MyForm, 'Visible', 0, true) then


      begin


        Log.Picture(w, 'Message ok');


          Aliases.MyProgram.MyForm.Close;


      end;


    end


    else


      Log.Warning('Message "non ok"')


    end;


     



    Example of WaitAliasChild :




    {------------------------------------------------------------------------------}


     


    function WaitAliasChildExample;


    var AliasObj;


    begin


      AliasObj := Aliases.MyProgram;


      if (AliasObj.WaitAliasChild('TFormMyForm', 100000).Exists ) then


        Log.Message('OK')


      else


        Log.Error('Non-OK');


    end;



    {------------------------------------------------------------------------------}



    But i just know how to do so only by the script, not with the Test Complete GUI.



    I have another question if you don't mind : I noticed that in Tools\Playback\ there is a checkbox "Stop on errors". What are the benefits to let it checked ?

  • chrisb's avatar
    chrisb
    Regular Contributor
    Stops test execution if an error occurs. See this: http://support.smartbear.com/viewarticle/63774/?_ga=1.48575334.1554134704.1392816096



    I'd suggest if you are eventually going to execute a suite of tests that you might also want to use  ' Events'  (http://support.smartbear.com/viewarticle/55502/?_ga=1.39778531.1554134704.1392816096)  for handling errors, warning, etc.



    For example because my test steps are heavily dependant on the previous test step (application state)  I use Event handlers to post a screenshot and message to test logs and then immediately exit the current test and start the next test in the run. 
  • simon_glet's avatar
    simon_glet
    Regular Contributor
    Hi Mehdi,



    As Chris answered the "Stop on errors" question, I will just say that we do not use Keyword testing because of it's edition limitations. We find it easier to code everything.



    From the postings on this forum, it seems that Keyword-Driven testing is aimed at testers that do not code. If you have to right building blocks, sure why bother ? ;-)



    Sincerely
  • m_essaid's avatar
    m_essaid
    Valued Contributor
    Thank you Chris, Simon and Jorge,



    Yes before using TC I'm a Delphi developper so scripting in a Delphi-like language seems easiest to me than using KeyWords driven tests.