Compare PDF Using Testmate| Picasso Visual Verification

Comparing PDF’s has become very easy using Testmate and Picasso Visual Verification. The PDF can be extracted into images using Testmate and then it can be validated against the existing or new baseline using Picasso.

The below code can be very self explanatory for this purpose:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'Declare variables - PDF's to compare
sPDFPath = "C:\Users\jaska\Desktop\pdftestmate\TestPDF.pdf"
sPDFtoCompare = "C:\Users\jaska\Desktop\pdftestmate\ToCompare.pdf"
 
'Set Variables for Picasso
'See more info at https://www.youtube.com/watch?v=aC3oV7sD2yA
sRootPath = "C:\Users\jaska\Desktop\pdftestmate\Sample"
sBasePath = sRootPath & "\Baseline"
 
'Fetch the current test Name
sTestName = util.Environment("Name")
 
'Create Baseline if not already created - This needs to be run only once.
'To Rebase delete the specific test folder in baseline - It will auto rebase it
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not(objFSO.FolderExists(sBasePath&"\" &sTestName)) Then
   objFSO.CreateFolder(sBasePath&"\" &sTestName)
 
   'Fetch the Page count of PDF
   iPageCount =  pdf.GetPageCount(sPDFPath)
 
   'Extract all the PDf images in the respective folder
   For iCount = 0 To iPageCount -1
      Call pdf.ExtractImage(sPDFPath,sBasePath&"\" & sTestName &"\Image"& Cstr(iCount)& ".bmp" ,iCount)
   Next
 
End If
 
 
'Generate a unique suite name for execution in Inbound
sSuiteName = Replace(Replace(Time,":","")," ","")
 
'Create suite folder
objFSO.CreateFolder(sRootPath&"\Inbound\" &sSuiteName)
 
'Create Test Folder
objFSO.CreateFolder(sRootPath&"\Inbound\" &sSuiteName &"\"& sTestName)
 
'Fetch the Page count of PDF
iPageCount =  pdf.GetPageCount(sPDFtoCompare)
 
'Extract all the PDf images in the respective Inbound folder
For iCount = 0 To iPageCount -1
  Call pdf.ExtractImage(sPDFtoCompare,sRootPath&"\Inbound\" &sSuiteName&"\" & sTestName &"\Image"& Cstr(iCount)& ".bmp" ,iCount)
Next
 
 
'Set the Path of the Picasso.exe - The below steps are optional and can also be performed manually
'See more info at https://www.youtube.com/watch?v=aC3oV7sD2yA
appPath = """" & "C:\Users\jaska\Desktop\pdftestmate\PicassoVisualverification\Picasso.exe" & """"
scriptPath = """" &sRootPath & "\Inbound\" & sSuiteName & """"
Command = appPath & " " & scriptPath
Set oShell = CreateObject ("WScript.Shell") 
oShell.Run Command
bSync = util.IsFIlePresent( sRootPath & "\Outbound\" & sSuiteName & "\report.html",20000)
oShell.Run """" &sRootPath & "\Outbound\" & sSuiteName & "\report.html"& """"

Add a Comment

Your email address will not be published. Required fields are marked *