Forum Discussion

jlmathre's avatar
jlmathre
New Contributor
8 years ago

When UI is locked, can TC be suspended and later resumed from the point of UI input? I use VBScript

Some test cases run many hours and the UI might lock out.  When the TC needs a keyboard input it will crash at that point.  I would like it to suspend and be able to be resumed by the operator at the input point.  I use vbscript.

 

  • karkadil's avatar
    karkadil
    Valued Contributor

    I like such challenging unusual tasks. Frankly speaking, I wasn't sure it is possible, but decided to try and found semi-automated solution which should work for you (note, that my example is in JScript, I am not very familiar with VBScript).

     

    0. Menu Tools - Options - Engines - Log. Make sure option Show Log on Pause is enabled.

    1. Create event handler for OnLogError event (you can read about it in the TC help system). The even handler should look like this:

     

    if(LogParams.MessageText == 'The operation cannot be performed, because the user session is locked.'){
        Log.Warning(LogParams.MessageText, LogParams.AdditionalText);
        BuiltIn.ShowMessage('Screen is locked. Perform last action manually then continue test execution...');
        Runner.Pause();
        LogParams.Locked = true;
      }

    2. When your workstation becomes locked and then unlocked, you'll see message box. Click OK - the execution will be paused.

     

    3. Switch to the current log tab in TestComplete and open Additional Text tab. There you will find information about the object TC was trying to interact with. You may also need to investigate Call Stack tab to understand, what exactly TC was trying to do when the error occured (e.g. click an object, type text, etc.).

    4. Perform the step from p.3 manually. There is no way to automatically redo the failed action, so you have to do it by yourself.

    5. Click Play button to continue running the test.

     

    P.S. You may also need to enable option EnableStackOnWarning somewhere in the OnStartTest event handler so that have access to the call stack during the pause.

    • jlmathre's avatar
      jlmathre
      New Contributor

      Thanks, this might work for the unpredictable situations.  For those tests that I know will take awhile I am thinking about adding some mouse movements to keep the window active.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Your better bet would be to configure the OS of the machine running the test to not auto-lock.  TC needs an interactive desktop to operate against any application.

    • jlmathre's avatar
      jlmathre
      New Contributor

      Being on a government computer it literally would require an act of Congress to change settings.  I would think this may be a common problem with tests going overnight or when the operator has to leave the system unattended for awhile.  There might be an event solution, just don't know enough about it.

  • jkrolczy's avatar
    jkrolczy
    Super Contributor

    We created a small script in MS VS and built an .exe file that when run, a small cmd window opens which you can resize

    and it runs for a period on time and presses the CTRL key.  It does this in a loop until you kill the cmd window.

    My computers locks in 15 mins. after no activity.  So this is my work-around.

     

     

    Since this is a gov computer, you probably cannot alter the win reg:

     

    i.e.

    Windows Registry Editor Version 5.00

    [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop]
    "ScreenSaverIsSecure"="1"
    "ScreenSaveTimeOut"="3600"