Comparing part of a .pdf with a Store.Region
I have a Store.Region of an image of a .pdf that looks like:
and I have a generated .pdf from my web application that looks like:
I'm trying to verify that the Logo is found on the .pdf and have tried all different kinds of:
With FindRegion is the StarsLogo found in the Sys.Process("Acrobat")
LogoFound2 = Regions.FindRegion(Regions.StarsLogo, Sys.Process("Acrobat"));
- returned "Cannot get a picture object from the input parameter."
I took a second image of the logo just to see if TC could compare two Store.Regions
Pict3 = Regions.StarsLogo2;
LogoFound1 = Regions.StarsLogo.Check(Pict3, false, false, 1, 1);
- returned "The region checkpoint "StarsLogo" failed. See Details for additional information." and Details is "Cannot get a picture object from the input parameter.".
your assumptions are correct
TC cannot compare images via the Regions comparison using stores objects on images on PDFs
TC can only compare images using the methods you are using when TC can recognize the images as an object themselves
At this time I am not aware of any other workarounds - the closest thing that you could potentially do is check the string value of your logo using an OCR checkpoint.
I do not agree that "Region Checkpoint" does not work, look at my screenshots I made specifically for you.
I want to immediately note that for correct work you need a license for "Intelligent Quality Add-On".
This is my objective and what I can't seems to get to work.
I did this instead.
var ManualResults = UserForms.ManualStarsLogoImageCheck.ShowModal();
if ( ManualResults == 6 ) /*Success */
Log.Message("AR9 meets ER9 'PASS' - The PDF will have a title of 'Checklist'");
else if ( ManualResults == 2 ) /*View Log */
Log.Warning("AR9 COULD meet ER9 'WARNING' – Unable top verify that the PDF HAD a title of 'Checklist'");
else if ( ManualResults == 7 ) /*Failure */
Log.Error("AR9 did NOT meet ER9 'FAILED' - The PDF DID NOT have a title of 'Checklist'");
Log.Error("The ManualResults value was not set by the UserForms.ManualReportImageCheck.ShowModal.");
Thank you, BMD
@A_Roskoshnyi I stand corrected! thank you for the clarification
@BMD , it looks like the solution above is using Regions.YOURPICTURE.Check() method to check precisely within the prescribed coordinates of your open pdf doc to find the region as described. This will behave as a checkpoint and fail your tests if it does not find it within that region.
def Test3(): #assuming you have the pdf you want to check open on screen, and the "pdf" variable below is referring to that on screen element pdf = Aliases.AcroRd32.wndAcrobatSDIWindow.AVFlipContainerView.AVDocumentMainView.AVFlipContainerView.AVSplitterView.AVSplitationPageView.AVSplitterView.AVScrolledPageView.AVScrollView.AVPageView #param1 = picture to search in (in my case entire page of PDF on my screen, aka variable called pdf #param2 = picture to search for (within the above pdf, aka the logo stored in my Stores-region item as "Logo") rect = Regions.Find(pdf, "Logo") if rect != None: x = rect.Left y = rect.Top width = rect.Width height = rect.Height pic = pdf.Picture(x,y,width,height) Log.Picture(pic, "found this image of the Logo") else: Log.Error("could not find the logo in your pdf")
the resulting logs will show you:
One final note is that if you change the DPI or resolution of the monitor that the test is created on vs the test being run on, this test will break (which is just the nature of using a pixel based Region method).
Otherwise, hope this helps, and once again, thanks @A_Roskoshnyi !
What a great conversation, Community!
@BMD does the advice help? please let us know.
Community and Education Specialist