Forum Discussion

atul_acrolinx's avatar
atul_acrolinx
Occasional Contributor
3 years ago

TestComplete How to exit immediately if object not found, rather than waiting for autowait to finish

Hi I am using Testcomplete for testing one desktop application..

 

In that I am searching for some window object on screen, (basically its an error window) - so requirement is - if that error window does not appear then continue

 

 

function verifyBrowserScriptErrorWindowAppears()
{
// Verifying an unexpected script error window is appearing before operation and if yes then closing it.
if(Aliases.xmetal.BrowserScriptErrorWindow.Exists)
{
Log.Message("Browser Script error window appeared.. Closing it..");
Aliases.xmetal.BrowserScriptErrorWindow.Close();
}
}

 

 

but everytime i call this method it keeps on searching window for 10 seconds (its detault search time of TC to search object) and then moves ahead.

 

SO my query is - How can i exit immediately if object is not there on screen, rather than waiting for that default time of object search.

5 Replies

  • How about this:

    function verifyBrowserScriptErrorWindowAppears()
    {
    // Verifying an unexpected script error window is appearing before operation and if yes then closing it.
    if(Aliases.xmetal.BrowserScriptErrorWindow.WaitProperty("Exists", true, 0))
    {
    Log.Message("Browser Script error window appeared.. Closing it..");
    Aliases.xmetal.BrowserScriptErrorWindow.Close();
    }
    } 
    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      What a great thread, thanks everyone for participating!

       

      atul_acrolinx which suggestion helped?

  • Hi atul_acrolinx - 

     

    You can change the autowait timeout at the project level Tools > Current Project Properties > Playback > Autowait Timeout. This is if you want to change the setting for all operations. 

     

    Or if you would like to switch it just for that one you can use this - you can set this to a very low time:

     

    Options.Run.Timeout = 30000; // 30 seconds

     Let me know if you have further questions.


    Emma

    • atul_acrolinx's avatar
      atul_acrolinx
      Occasional Contributor

      Thank you ebarbera  for info, yes I tried this but then If i do this then it will affect entire project object identification process, wherein when I really want TC to spend some time to find object, then it will fail there.

       

      But just wanted to understand if there is any way to do this using script or something... 

       

      like look for object if not then exist immediately.. not sure how much logical or feasible question is.. 

      Thanks in advance. 

      • MarkHays's avatar
        MarkHays
        Occasional Contributor

        So, as @ebarbera indicated you can change the timeout value in a script.   Perhaps first you will  want to get the current value store it in a variable and then restore it after you have checked for the object existence such as

         

        timeout = Options.Run.Timeout

        Options.Run.Timeout = 2000  # 2 seconds

        # code to Perform check

        Options.Run.Timeout = timeout    # restore the timeout value to the previous time