cancel
Showing results for 
Search instead for 
Did you mean: 

Modify Auto-Wait Timeout through Code

SOLVED
Highlighted
Occasional Contributor

Modify Auto-Wait Timeout through Code

Hi Folks, 

Due to a design problem of TestComplete Exists method does not provide additional overload of maxtimeout millisecond parameter and it does wait until time specified in Project Properties > Auto-Wait Timeout, which makes the situation worse. I want to know if it is somehow possible to adjust this implicit timeout property though code.

 

I am really pissed off with SmartBear's attitude of rejecting a great suggestion which help everyone "just to add just another overload in the existing Exists function, which will start accepting the timeout" and overloads does not impact existing signature.

 

 

Please do not suggest me to use WaitNNN, its a most stupid API design I have ever seen.

 

Thanks,

Manish Bansal 

 


Thanks,
Manish Bansal
1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

Re: Modify Auto-Wait Timeout through Code

You can change the auto-wait timeout like this:

 

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

 


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

5 REPLIES 5
Highlighted
Contributor

Re: Modify Auto-Wait Timeout through Code

I'm not sure if I understand. But when you want to expect something you can use as well. Adding a variable to control the maximum time.

var time: integer;
while not (Sys.Waitprocess ('Doro'). Exists) of
   begin
     time: time + = 500;
     Delay (500);
     if (time = 10000) then
         Log.error ('Error');
     end;
end;

When you want to wait other objects etc. You change only while the condition for example.

Another thing that can help, it would for example. As every time the TestComplete does not find the object (mapping) it calls the TIMEOUT time. Not to call you will:


var time: integer;
begin
time := 0;
Options.Run.Timeout: = 0;
while not (Sys.Waitprocess ('Doro'). Exists) of
   begin
     time := time + 500;
     Delay (500);
        if (time = 10000) then
             Log.error ('Error');
        end;
end;
// After waiting you expect you assign the value of nomal timeout
Options.Run.Timeout: = 10000;
 
I hope this helps = D
Highlighted
Contributor

Re: Modify Auto-Wait Timeout through Code

OK, think I understand what you mean, you want to set your own maximum time to wait for an object to exist rather than use the auto-wait timeout that is set for the project? 

 

A function like the one below will wait for the object to exist or until the max time is reached:

 

function WaitUntilExists(object, maxTime)
{
  var wait = 0;

  while(object["Exists"] != true && wait < maxTime)
  {
    // Delay for 1 second
    Delay(1000);
    // Add the delay time on to the total wait time
    wait += 1000;
  }
}

 

So you would call it like:

 

// This would wait for someObject for 10 seconds

WaitUntilExists(someObject, 10000);

 

// This would wait for someObject for one hour

WaitUntilExists(someObject, 3600000);

 

 

Moderator

Re: Modify Auto-Wait Timeout through Code

You can change the auto-wait timeout like this:

 

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

 


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

Highlighted
Occasional Contributor

Re: Modify Auto-Wait Timeout through Code

folks,

Thanks for awesome replies, this is what I was looking, Smiley Happy

 

Options.Run.Timeout = 30000;

 

Similarly we control implicit timeout in selenium.

 

I have now come up with 2 functions based on the above solution.

 

WaitForExists(expectedObject, MaxTimeOutInSec) 'usual wait 
WaitTillExists(currentObject, MaxTimeOutInSec)  'this would be used when we are expecting some popup window should hide after doing some action, but it is taking long time

 


Thanks,
Manish Bansal
Highlighted
Regular Contributor

Re: Modify Auto-Wait Timeout through Code

Hi folks,

I've also got a solution for this task, see attachment.

I'm sorry, it is written in german language.

 

It is a class in a script extension, and it is used as follows:

' set Your timeout

Set Timeout = PVA_0.TC.SetRuntimeoutObj(projectsuite.Variables.WaitExMs, mcModul & cRoutine)

[object var   ]     [script                                          [new timeout in ms]                                  [name of originator ]

                           extension namespace, module, routine]

 

' reset to previous timeout

Timeout.Restore

 

 

It comes with some advantages:

- it can be used hierarchically in subroutines

- Timeout is also reset automatically as soon as the object variable is destroyed after the defining routine is left.

- it comes with a threshold (german: "Schwelle") for reduction: only if the reduction is more than a certain factor, it is executed. This is for performance issues, as on my pc, changing the auto-wait timeout requires 4 ms of time

- the routine name of the originator is comprised for debugging purposes

 

The code is meant to be located in a script extension, so some global Objects have to be handed in when the test is started:

PVA_0.TC.Initialize Win32Api, Options

(locate in  GeneralEvents_OnStartTest)

and has to be freed after stopping:

PVA_0.TcLog.Terminate

 

(locate in  GeneralEvents_OnStopTest)

 

enjoy using it

Manfred

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors