Forum Discussion

rpd's avatar
rpd
Contributor
8 years ago

How to use OCR feature within Test Complete to find strings within screen image?

I have an IBM mainframe based application under CICS and I want to be able to select numeric data from within the 24 row by 80 column application area of a standard 3270 Emulation screen. I am using Rocket's software emulation software to connect to the IBM Mainframe. The process name for that emulation software is BZMD.EXE.

 

In the Test Complete Help document, there is a discussion of using Test Complete's OCR feature to find text within an image. Due to the nature of the 3270 emulation screen, Test Complete cannot identify individual numeric data from within the 24 row by 80 column application area. All Test Complete can do is get an IMAGE of that application area.

 

Consequently, I want to use the OCR feature to find recognizable text within that 24 row by 80 column application area.

 

In the Test Complete Help documentation, there is a one-line command to capture the Active Window image and then let the OCR feature find all recognizable text in that image. Since the 3270 emulation screen just contains alphanumeric characters in the 24 row by 80 column application area, this should be EASY to do. Here is that command:

 

Log.Message(OCR.CreateObject(Sys.Desktop.ActiveWindow()).GetText());

 

Since the name of the 3270 emulation process is BZMD.EXE, I have  modified the above  command as follows (Note that I got the window name by using the Object Explorer feature of Test Complete):

 

Log.Message(OCR.CreateObject(Aliases.bzmd.wndBlueZoneMainframeDisplayS1.SessionDisplay).GetText());

 

I have included the modified line within a Run Code Snippet in my Test Complete testcase. Unfortunately, when I run this testcase, the OCR feature does not recognize ANY text.in that window. All I get is a message in my testcase's log that looks like binary or image data of some type.

 

Am I NOT specifying the Log.Message.... command correctly within the Run Code Snippet?

 

Any help would be appreciated.

 

 

5 Replies

  • clay's avatar
    clay
    Contributor

    I have some limited experience with OCR that I will share...

     

    I recommend that chop the one-liner into pieces and break down the problem you are trying to solve.  My gut tells my that you are not capturing the image correctly.  You could try something like this (in JavaScript)...

     

    var region;

    var pic;

    var ocr;

    var myText = "";

    var attr = Log.CreateNewAttributes();

    try

    {

        //

        // Capture the image to a region

        region=Regions.CreateRegionInfo(Aliases.ProgramName.ViewPath,  1, 1,

            Aliases.ProgramName.ViewPath.Width, Aliases.ProgramName.ViewPath.Height, false); 

        //

        //Get the image from the region.

        pic = region.Picture(); 

        //

        //Create an OCR object using the image.

        ocr = OCR.CreateObject(pic); 

        //

        //Get the text from the OCR object.

        myText = ocr.GetText();

        Log.Message(myText, "", pmNormal, attr, pic, -1)

    }

    catch(err)

    {

        Log.Error(err.message, "", pmNormal, attr, pic, -1);

    }

     

    I recommend you step through the debugger and find out where the problem occurs.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Have you tried using TextRecognition instead of OCR?  you might find that works better for terminal emulations.

    • rpd's avatar
      rpd
      Contributor

      I have used the Text Recogntion feature as well as Extended Text Recognition. In both cases, the Test Complete Object Explorer can NOT identify any objects within the 24 row by 80 column application area of the 3270 emulator screen. All of these object(s) are listed as HIDDEN, not visible objects,  by the Test Complete Object Explorer. As a result, it is not possible to select any of these objects and use their object properties to get access to whatever data is shown in those object properties.

       

      Also, I have heard from other sources, that since the text on the 3270 emulation screen in colored (ie. not white text on a black screen but colored text on a black screen), that the OCR recognition will be more difficult to accomplish.

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        If it was anything else than scraping text from the screen...

         

        ... with the emulator you're using, can you change the interface so it is black text on white background?