Ask a Question

Waiting for OCR checkpoint to appear as screen loads

SOLVED
david_vickers
Occasional Contributor

Waiting for OCR checkpoint to appear as screen loads

I'm using a OCR checkpoint to wait for a Citrix application and display a login prompt.  When the window appears there's a brief loading screen that displays before the login prompt that I'm using the checkpoint to validate.  The OCR checkpoint ends up detecting the loading screen and then failing because it's not the login prompt.  

 

Is there a way to set up a delay/wait for the login prompt to appear despite what TestComplete first detects from the object window?  It would need to actually wait the specified timeout for the text to appear instead of failing at what it first detects.  

 

Thanks in advance

 

15 REPLIES 15
BenoitB
Community Hero

KWT ou script ?

 

4 choices:

- add a delay of the maximum time needed to have this loading screen (aqUtils.Delay(delay in ms).

- add an ocr checkpoint to detect the loading screen prior the login ocr checkpoint

- changes the ocr value checked to take in account the text behind the loading screen

- change nothing but add error management on your login prompt and if failed make a retry

Un sourire et ça repart

AlexKaras
Champion Level 3

@david_vickers :
Hi,

 

To rephrase what was written by @BenoitB :

By definition, checkpoint is an action that performs some validation. In your scenario you are not validating, but waiting for some object/image to appear. Thus you should not use checkpoint but need to wait (via one of the .WaitXXX() methods) or wait in a loop until the sought for object/image appears or timeout occurs.

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================

I think he can't use Waitxxx because it's on a Citrix receiver so only graphic (image or OCR).

Un sourire et ça repart

david_vickers
Occasional Contributor

Thanks BenoitB for the suggestions.  Here's my thoughts on them and correct me if I'm understanding this wrong:

 

- I rather not relay of wait/sleep commands since it would slow down the script.  Plus they're not dependable since the loading screen duration could vary based on load/stress

- I could add a checkpoint for the loading screen, but the risk is that after I check and then proceed, the loading screen may still be present.

- There's no text behind the loading screen.  It displays on the screen and will disappear once the login completes and the application dashboard appears.

- Error management/trapping may be the best approach. Is there a way to do this with a keyword test, or would it be best to do this via script?

 

I'll also add the same behavior is happening when using an OCR Action.  Since my Citrix window is always displayed, switching between screens in the application is going to be a challenge because I run into the risk of grabbing text from the current screen with an OCR Action when I need the script to wait until the new screen appears.  

david_vickers
Occasional Contributor

Thanks @AlexKaras,

 

Is there a sample that you could point me to on how to implement a loop check?  I would be using it multiple times within my test script as I navigate screens, so hopefully I can use it in a function/subroutine.

Hi,

 

Exact implementation might depend on your needs and tested application.

 

there's a brief loading screen that displays before the login prompt

For example, one project had this code to wait until the spinner object disappears:

 

  // wait until spinner is hidden and control is populated with data
  oSpinner = oCombo.Parent.FindChild(
      ["ClrClassName", "WPFControlOrdinalNo"], ["ProgressIndicator", oCombo.WPFControlOrdinalNo], 3);
  iStartTime = Win32API.GetTickCount();
  iStopTime = iStartTime + timeout;
  while(((oSpinner.Visible) || (0 == oCombo.wItemCount)) && (iStopTime >= Win32API.GetTickCount()))
    aqUtils.Delay(500);

  if(Win32API.GetTickCount() > iStopTime)
    Log.Warning(
        aqString.Format("Control was not populated with data within %i sec timeout",
          aqConvert.VarToInt(timeout / 1000)),
        aqString.Format("Target combo-box: %s", oCombo.FullName),
        BuiltIn.pmNormal, null, Aliases.<tested app window>.Picture());
...

 

 

Hope, you got the idea.

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================

Two questions and one remark if you don't mind on your sample :

 

- Good idea to use getTickCount, it's not using a Timer object like StopWatch (HISUtils) so ligther on the system, ;^)

 

- Why checking Visible and not VisibleOnScreen ? I've lot of projects where spinner or toaster are Visible because preloaded on page but not VisibleOnScreen till they need for.

 

- Why checking count of items of the combo, so here if items = 0 it's not the combo not available but the data of the combo which aren't available (data vs ihm) ?

 

 

Un sourire et ça repart

@BenoitB :

 

Hi,

 

Why checking Visible and not VisibleOnScreen ?

a) This is my preference over .VisibleOnScreen; and

b) It worked for that project.

.Visible means that the given object is visible somewhere. It may be out of window/viewport bounds or be overlapped by some other control, but .Visible still will be True. .VisibleOnScreen means that the given object is visible to the user on the screen at the given moment. If the element is, for example, overlapped (like in the case when one has TestComplete's window on top of the tested application. In this case .VisibleOnScreen for all elements will be False.) then .VisibleOnScreen evaluates to False.

Note: Web applications have their specifics and the above rules might not work depending on page scripting, css rules, etc.

 

if items = 0 it's not the combo not available but the data of the combo which aren't available

Correct. And this is what was required in that case. And the warning message says exactly this - that the data was not provided, but not that the control itself in unaccessible. 🙂

 

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================

Txs @AlexKaras,  i knew exactly what you will say 😉  but making this kind of discussion help people to learn and improve 🔆

 

One more thing to know between Visible and VisibleScreen, is that evaluating VisibleOnScreen is longer for the TC engine than Visible.

 

So choice between of the 2 properties is often technology dependent but also test-logic dependent (If you want to really check if it's visible for the user, you must use VisibleOnScreen).

 

As for me, on web pages due to tech used making component visible true as not really visible but just ready for, i choose VisibleOnScreen but on heavy-client i choose Visible.

 

Un sourire et ça repart

cancel
Showing results for 
Search instead for 
Did you mean: