Get OCR Text: value in exception of TryCatch

HI,

I get this error sometime when it can’t scrap the text. I can see text in the box, but Screen Scraping had difficulty reading it.
Is there a way to read this so it wont stop my robot process… so i can create an if statement on that…
image

thanks for the help in advance…

2 Likes

1.) Make sure your selector is pointing to the data containing the text.
2.) Make sure the language is set properly
3.) Try different screen scraping methods and scales until you find a result that returns the data you’re looking for. This is something you’ll have to experiment with.

2 Likes

The scale and langage is perfect… but out 50 maybe 10 time it gives me this message…

Is there a way to read the value “Scrap returnes empty text”

2 Likes

You can get this by wrapping your Read OCR Text activity in a Try/Catch block. In the Catch block, you can check for this message by getting the value exception.Message.

3 Likes

Ok i will try. thanks

2 Likes

@Anthony_Humphries

I tried with Try Catch actvity… I got what i want… I did like this…
I do area of attach window I added… try catch…
image
image
and then im using this strExceptionMessage varibale in IF to go to different way…

But know the problem is… that I only need to use the try catch when ORC can not scrap a value…
And when OCR can scrap a value then i do not need the try catch…

And right now with this what i did it also showing 0 where it could scrap value first… so what should i do now?? as is has solved my one problem but has given another issue :frowning:

pleasse help

2 Likes

You can create an If statement that checks the value after it has been fetched. If it does not match what you’re expecting, handle the process as you would like to (e.g. throw an exception, create a report, etc). As for configuring OCR to properly read the document, you will need to experiment with the settings until you get the desired result.

2 Likes

do you means by an if statement in catch area?

2 Likes

No, the If statement would follow the OCR activity in the Try block, since getting text is not an error and won’t trigger entry into the Catch block.

2 Likes

ok but my problem was… when this OCR was throwing “empty value text” due to it can not scrap the text. by adding try catch I got this problem solve… but now when this can read the value it showing me no value… because there is no exception due to ocr is able to read the value…

But it not showing me the value in output… due to try catch…
how can i solv that…

2 Likes

If OCR reads no value, but does not fail, you’ll need to handle this in an If statement in the Try block. Catch only gets triggered when an error occurs. You’ll have two places where you’ll need to handle the errors: once in the If statement, and once in the Catch block.

3 Likes

Perfect… thank buddy i will try now…

2 Likes

HI @Anthony_Humphries

I did like this…
In Try area I have only the Get OCR Text and in Catch I chosse “system.exceptions” as you told and then i did a log message and IF statement.
Get OCR Text error message is “Scrape returned empty text.”
In IF condiiton I putted value as: exception.ToString = “Scrape returned empty text.” then 2 different way it has to go after.
Now problem is, its not going to furthe IF Statement.

can you help.

2 Likes

Log the message exception.ToString before you reach the If statement and make sure it matches what you’re checking for in your If statement. The two messages might be off by a character or two.

1 Like

I did that and, its working when the it has exception… means its moving on Then side from IF statment.

But when there is no exception then i want it’s continue to the Else side and it’s not doing that…
when there is no exception error then it has to show me the right value from that OCR variable (recurringIntRateValue) it has catched and go further on basis of that…

But its not working. :’(

1 Like

Move the sequence for your Else after the entire Try/Catch block. The code under Catch only gets executed when there is an exception.

1 Like

I did that before for wrote it…
thanks for the help Now I got understanding of how and when to use try catch …

bundle of thanks.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.