Waiting for OCR checkpoint to appear as screen loads
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
Checkpoints
-
Keyword Tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alex, Benoit - great discussion indeed!🙂
@david_vickers I hope you found the suggestions helpful. Would be great if you could mark the best reply as a solution here!
Sonya Mihaljova
Community and Education Specialist
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @AlexKaras , I'm trying to find how to modify this to use OCR.Recognize method. I found an example here: https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/ocr/check/wait.ht... but I'm unable to get the code working.
Using this code:
function CheckTextContents(anObject, aSubstring, caseSensitive)
{
// Recognize the text contents of the specified onscreen object
var text = OCR.Recognize(anObject).FullText;
// Search for the occurrence of the specified substring in the recognized text
return (aqString.Find(text, aSubstring, 0, caseSensitive) > -1)
}
and then from the keyword test (see attached)
When I run the test, I get a "Type Mismatch" error on the following line
var text = OCR.Recognize(anObject).FullText;
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> When I run the test, I get a "Type Mismatch" error on the following line
> var text = OCR.Recognize(anObject).FullText;
I would either split the second line of code into two lines (in order to figure out whether it is .Recognize() or .FullText that fails) or put a breakpoint on this line and try to use the Evaluate dialog to check that anObject contains correct value and that OCR.Recognize(anObject) returns correct recognized text.
/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
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@AlexKaras Discovered the reason for the "Invalid Text" error. When selecting the parameters in the Keyword test area, for setting the parameter I was using a String type instead of Object type. The solution from the support site actually works really well for me. The only issue with it is that it's a infinite loop, so I modified the sample code and used a for loop instead to emulate a 10 second timeout (I could also pass another parameter for the seconds)
function CheckTextContents(textToSearch)
{
// Recognize the text contents of the specified onscreen object (Citrix window)
var text = OCR.Recognize(Aliases.wfica32.wndTransparentWindowsClient).FullText;
// Search for the occurrence of the specified substring in the recognized text
return (aqString.Find(text, textToSearch, 0, false) > -1)
}
function WaitForText(textToWait)
{
for (x = 0; x < 10; x++) {
if (! CheckTextContents(textToWait))
Delay(1000);
else
break;
}
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Beware that your function WaitForText could return without information in case of no text apparation within the 10 seconds.
function WaitForText(textToWait, timeout = 10000) {
startTimer = Win32API.GetTickCount();
maxTimer = startTimer + timeout;
while (Win32API.GetTickCount() < maxTimer) {
if (CheckTextContents(textToWait))
return true;
aqUtils.Delay(250)
}
return false;
}
Un sourire et ça repart
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> I was using a String type instead of Object type.
And this may be solved with the help of eval() (or evaluate() whatever is supported by the script language your project is based on) function.
Like this:
function CheckTextContents(textToSearch)
{
var obj = eval("Aliases.wfica32.wndTransparentWindowsClient");
// Recognize the text contents of the specified onscreen object (Citrix window)
var text = OCR.Recognize(obj).FullText;
// Search for the occurrence of the specified substring in the recognized text
return (aqString.Find(text, textToSearch, 0, false) > -1)
}
Just a hint... 😉
/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
================================

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »