Forum Discussion
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.
While the solution above is using a Keyword test, you can follow the steps shown in the screenshots and right-click convert to script the KDT to get your javascript sample.
Another option would be to use the Regions.Find() method. In this case, you will describe a picture to search in (the open pdf page in question) and the picture you want to find (the logo you stored in the Stores.Region test item). I work the fastest in python so heres my sample (but the syntax should be similar so you can convert most of it into javascript if needed):
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 !
Related Content
- 2 years ago
- 2 years ago
- 5 years ago
- 7 years ago