In TestComplete, you use PDF checkpoints to verify the actual text content of the specified PDF files by comparing it with the baseline data stored in the Stores > Files collection of your project.
PDF checkpoints in TestComplete take two parameters:
-
The name (with the full path) of the PDF file you want to verify.
-
The allowed difference value (in bytes).
By default, PDF checkpoints you create use hard-coded parameter values. You may want to parameterize your PDF checkpoints, that is, to replace hard-coded values with variable values. For example, if the name of the file you want to verify changes between test runs, you can replace the hard-coded file name with a parameter that obtains the required file name before each test run.
In keyword tests
-
Create a variable or parameter that will contain the needed variable value. It can be:
-
A keyword test variable. You create it on the Variables page of your test.
-
A project or project suite variable. You can create them on the Variables page of your project or project suite respectively.
-
A test parameter. You create it on the Parameters page of your test.
For example, the image below shows the Param1 parameter of a keyword test:
-
-
Replace the hard-coded value of the PDF Checkpoint operation with the created variable or parameter:
-
Assign the needed value to the created variable or parameter:
-
To set a variable value, you can use the Set Variable Value operation.
-
Set a parameter value when you run your test. If you run it as part of the project’s test items sequence, set the test parameter in the Execution Plan editor of your project. If you run your test from another test, set the parameter value when calling your test.
For example, the image below shows how to set a parameter value in the Execution Plan editor of the project:
-
-
Run the test with the needed parameter value assigned.
In scripts
-
Define a variable or parameter that will contain the needed variable value.
JavaScript, JScript
function ValidatePDF(Param1)
{
…
// Validate the PDF file
Files.sample.CheckPDFText("C:\\Users\\tester\\Documents\\sample.pdf");
…
}Python
def ValidatePDF(Param1):
…
# Validate the PDF file
Files.sample.CheckPDFText("C:\\Users\\tester\\Documents\\sample.pdf")
…VBScript
Sub ValidatePDF(Param1)
…
' Validate the PDF file
Call Files.sample.CheckPDFText("C:\Users\tester\Documents\sample.pdf")
…
End SubDelphiScript
procedure ValidatePDF(Param1);
begin
…
// Validate the PDF file
Files.sample.CheckPDFText('C:\Users\tester\Documents\sample.pdf');
…
end;C++Script, C#Script
function ValidatePDF(Param1)
{
…
// Validate the PDF file
Files["sample"]["CheckPDFText"]("C:\\Users\\tester\\Documents\\sample.pdf");
…
} -
Replace the hard-coded parameter of the
Files.PDF_File_Name.CheckPDFText
method with the created variable or parameter:JavaScript, JScript
function ValidatePDF(Param1)
{
…
// Validate the PDF file
Files.sample.CheckPDFText(Param1);
…
}Python
def ValidatePDF(Param1):
…
# Validate the PDF file
Files.sample.CheckPDFText(Param1)
…VBScript
Sub ValidatePDF(Param1)
…
' Validate the PDF file
Call Files.sample.CheckPDFText(Param1)
…
End SubDelphiScript
procedure ValidatePDF(Param1);
begin
…
// Validate the PDF file
Files.sample.CheckPDFText(Param1);
…
end;C++Script, C#Script
function ValidatePDF(Param1)
{
…
// Validate the PDF file
Files["sample"]["CheckPDFText"](Param1);
…
} -
Assign the needed value to a variable or parameter and call the parameterized checkpoint:
JavaScript, JScript
function Main()
{
var path = "C:\\Users\\tester\\Documents\\sample.pdf";
ValidatePDF(path);
…
}
function ValidatePDF(Param1)
{
…
// Validate the PDF file
Files.sample.CheckPDFText(Param1);
…
}Python
def Main():
path = "C:\\Users\\tester\\Documents\\sample.pdf"
ValidatePDF(path)
…
def ValidatePDF(Param1):
…
# Validate the PDF file
Files.sample.CheckPDFText(Param1)
…VBScript
Sub Main()
path = "C:\Users\tester\Documents\sample.pdf"
Call ValidatePDF(path)
…
End Sub
Sub ValidatePDF(Param1)
…
' Validate the PDF file
Call Files.sample.CheckPDFText(Param1)
…
End SubDelphiScript
procedure ValidatePDF(Param1);
begin
…
// Validate the PDF file
Files.sample.CheckPDFText(Param1);
…
end;
procedure Main();
var path;
begin
path := 'C:\Users\tester\Documents\sample.pdf';
ValidatePDF(path);
…
end;C++Script, C#Script
function Main()
{
var path = "C:\\Users\\tester\\Documents\\sample.pdf";
ValidatePDF(path);
…
}
function ValidatePDF(Param1)
{
…
// Validate the PDF file
Files["sample"]["CheckPDFText"](Param1);
…
}
See Also
PDF Checkpoints
Creating PDF Checkpoints
Parameterizing Keyword Tests
Parameterizing Script Routines