cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid Bitmap using Legacy OCR

SOLVED
Highlighted
Occasional Contributor

Invalid Bitmap using Legacy OCR

I have a number of application fields (Uniface unitext), They contain text but Testcomplete does not expose the wText (It appears unable to recognose any of the field content, although all properties exist, no content is exposed), As my environemt is secure (no external access) I am unable to exploit the IQ addon, my options are Text Recognition or OCR, Text Recognition does not appear to work with Uniface (A search for known text on screen returns nothing!) My hope hangs on Legacy OCR however when calling Set octObj = OCR.CreateObject(picObj) I get a runtime error Invalid Bitmap.

 

I know which UniText field I need to interigate by its .top and .left properties, All I am trying to do is produce a nice clean checkpoint in the log file!

 

picObj is set to FormObj.Windows("UniText","",19).picture

 

log.picture picObj, "Image to Ocr"  

 

Is producing a very nice logged picture of the UniText field  in this case its a duration ie 12345:12

 

Am I missing something here?  is the deafult object.picture not a bitmap?

 

My hope was to do something like

 

Set FormObj = Incredibly long uniface path to unicanvas containing the objects of interest...

picObj = FormObj.Windows("UniText","",VarIndex).picture

log.picture picObj, "Image to Ocr" 

Set ocrObj = OCR.CreateObject(picObj)

ocrText = ocrObj.GetText()

if ocrText = varExpValue then

  log.checkpoint "Checkpoint passed " & ocrText

else

  log.error "Checkpoint failed value " & ocrText & ", expected " & varExpValue

  runner.stop

End if

Set ocrObj = Nothing

Set FormObj = Nothing

 

I am allready checkpointing the data via a direct database read, so I know the retrieved value should be ok, however I really want to check the screen value presented to users...

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Invalid Bitmap using Legacy OCR

Hi,

 

picObj = FormObj.Windows("UniText","",VarIndex).picture

Unless it is a typo in the post, picObj must be Set :

Set picObj = FormObj.Windows("UniText","",VarIndex).picture

Does this help?

Otherwise, I did not spot anything wrong in your code sample and you may ask Support directly via the https://support.smartbear.com/message/?prod=TestComplete form.

 

One more possible approach is to:

-- select all text in a field;

-- copy it to the clipboard (via the <obj>.Keys("^c") call)

-- assign to script variable (e.g. aFieldVal = Sys.Clipboard);

-- use this script variable for checkpoint.

Note: as clipboard is a shared resource, it is recommended to assign its value to the script variable as soon as possible to avoid possible overwrite.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

6 REPLIES 6
Highlighted
Occasional Contributor

Re: Invalid Bitmap using Legacy OCR

Changing project properties Image fomat to BMP make no difference.

 

Saving image to file system...    Call PictObj.SaveToFile("c:\temp\chkpoint.bmp")

and then loading also makes no difference, I always end up with Invalid Bitmap

Highlighted
Community Hero

Re: Invalid Bitmap using Legacy OCR

Hi,

 

picObj = FormObj.Windows("UniText","",VarIndex).picture

Unless it is a typo in the post, picObj must be Set :

Set picObj = FormObj.Windows("UniText","",VarIndex).picture

Does this help?

Otherwise, I did not spot anything wrong in your code sample and you may ask Support directly via the https://support.smartbear.com/message/?prod=TestComplete form.

 

One more possible approach is to:

-- select all text in a field;

-- copy it to the clipboard (via the <obj>.Keys("^c") call)

-- assign to script variable (e.g. aFieldVal = Sys.Clipboard);

-- use this script variable for checkpoint.

Note: as clipboard is a shared resource, it is recommended to assign its value to the script variable as soon as possible to avoid possible overwrite.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
Community Leader

Re: Invalid Bitmap using Legacy OCR

Wht is the color depth of the screen tested ?

Perhaps a problem on 8, 16, 24, 48 bits ?

Un sourire et ça repart

Highlighted
Occasional Contributor

Re: Invalid Bitmap using Legacy OCR


@AlexKaras wrote:

Hi,

 

picObj = FormObj.Windows("UniText","",VarIndex).picture

Unless it is a typo in the post, picObj must be Set :

Set picObj = FormObj.Windows("UniText","",VarIndex).picture

 


Yep it was a type in the Forum not the script....  I will raise a support ticket as suggested...

 

For the meantime the copy text to clipboard is a simple work of genius and suits my needs perfectly!

 

It provides a nice workaround to my issue 🙂 Thankyou

 

Highlighted
Community Manager

Re: Invalid Bitmap using Legacy OCR

Thanks everyone for participation!

 

@Joberry I am glad to hear you've found a workaround!

Please keep us posted in this thread about you support investigation results.

In the meantime, I'll mark the workaround as a temporary solution.


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Community Hero

Re: Invalid Bitmap using Legacy OCR

Hi,

 

the workaround as a temporary solution.

You may consider this as a self-promotion 🙂 ...

Though as @Joberry was looking for text checkpointing and as long as the approach with clipboard use suits the needs, I expect better performance and reliability from clipboard approach when compared to the OCR one which might be not too accurate sometimes.

I would appreciate it if @Joberry let us know the reply from Support about the OCR case that was observed.

OCR and clipboard are just two different approaches for the given case. The potential risk of clipboard-based approach is that in the environments with the shared clipboard (e.g. when several remote desktop sessions are opened on the same host with tests running in one RDP window and user working in another RDP window) there is a chance of clipboard content to be overwritten. That is why it is recommended to copy a value to the clipboard and store it to the variable as soon as possible.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Here?
Join us and watch the welcome video:
Top Kudoed Authors