Region Checkpoint - OCR
- 4 years ago
That was helpful. Thanks!
So, I ended up creating a function that I could parameterize by calling the Run Script Routine in my keyword test.
I can use this over and over again for both web pages and PDFs.The only inconvenience with this is getting the correct parameters--clientX, clientY, width, height--into my Run Script Routine.
I end up using the Post Screen Shot keyword test to select the relevant area.Then I read those values from the Post Screenshot keyword test, and type them into my parameterized routine.
I think this is more reliable (less prone to false errors) than calling a Region Checkpoint. Often with Region Checkpoint, the text in question can be an exact match, but the test returns false due to a slight shift in pixels horizontally and/or vertically.
This is also a good option when I'm working on highly dynamic web sites and the xpath may not be reliable from page view to page view--especially around modal popups.
I'm wondering if TestComplete will ever create a keyword test like this?
I'd like to drop a keyword test in place, select the screen area in question (not xpath), and then OCR the text just from that region and check for the desired text.
Do you think TestComplete will ever make this kind of feature?function verify_text_present(clientX, clientY, width, height, textToFind) {
w = Sys.Desktop.ActiveWindow().Picture(clientX, clientY, width, height);
var recognizedText = OCR.Recognize(w);
if (aqString.Find(recognizedText.FullText, textToFind, 0, false) > -1) {
Log.Message("Found " + `"` + textToFind + `"` + "in the following text OCR extracted from the specified screen area:" + "\n\n" +recognizedText.FullText);
return true;
} else {
Log.Message("Did Not Find " + `"` + textToFind + `"` + "in the following text OCR extracted from the specified screen area:" + "\n\n" +recognizedText.FullText);
return false;}
}