TestResults.io
  • What is TestResults.io
  • System Architecture
  • Regulated Markets
    • Health Care Industry
    • Financial Services Industry
  • What's new?
    • Update Instruction
      • Update of the Designer extension in Visual Studio
      • Update the Execution Engine
      • Update the Base- and Environment Models
    • Migration to new project file
  • Designer
    • Overview
    • First Steps
    • Installation
    • TestResults.io solution
    • The development environment
      • Tool Window Overview
        • Test Environments
          • Steps to configure a SUT VM
          • How to access files on the system under test
        • Remote Viewer
          • Control Mode
          • Capture Mode
          • Screen Editor
          • Capture Single Image
        • Screen Explorer
        • Test Case Designer
        • Image Explorer
        • API Testing
        • TestResults.io options
          • Engines
          • Servers
    • Test Cases
      • Adding Test Cases
      • Test Case structure
      • Simple Test Case (Example)
      • Executing your Test Case
      • Generating Test Containers
      • Publishing Test Cases
      • Execution Variables
    • Software Models
      • Adding SW Models
      • Referencing the Model in the Test Case
      • Generating Test Containers
      • Publishing SW Models
      • Screens and Screen Elements
        • Tables
        • Visual Sense
        • Custom Screen Elements
    • Installers
      • Adding Installers
      • Generating Test Containers
      • Publishing Installers
    • Automation Framework Reference
      • Attributes
      • Enumerations
      • Filters
        • IImageFilter Interface
        • Select
        • Resize
      • GlobalEngineParameters
      • ImageDetectionParameters
      • ImageReference
      • Interfaces
        • ITester Interface
          • ITester Methods
          • ITester Properties
        • ITestee Interface
          • ITestee Methods
        • IConnections Interface
          • IConnections Methods
          • IConnections Properties
        • IDebug Interface
        • IEngineResult
        • IHelpers Interface
        • IImageHelper Interface
          • IImageHelper Methods
        • IKeyboard Interface
          • IKeyboard Methods
        • IMouse Interface
          • IMouse Methods
          • IMouse Properties
        • IReport Interface
          • IReport Methods
        • ISUTConnection Interface
      • OcrEngineParameters
        • Best practise
        • IronOcrEngineParameters
        • LEADOcrEngineParameters
        • OcrEngineRelatedCharacters
        • OcrPreprocessingParameters
      • ResultRectangle
      • SutNotReadyException
      • TestStepAbortedException
    • FAQ
      • Two-factor authentication (2FA) and One Time Passwords (OTP)
      • Receive and verify Emails
      • Using Excel as test data source
      • Verify PDF Content
  • Portal
    • Overview
    • First Steps
    • User's Guide
      • Login
      • Projects
      • Dashboard
      • Test Cases
      • Software & Environments
      • Test Sets
      • Job Queue
      • Management
      • Notifications Summary
    • Automation Engineer's Guide
      • Test Automation Workflow
      • Automating a test case
      • Enabling Software & Environments
    • REST API Reference
      • Authentication
      • Projects
      • Test Sets
      • Test Cases
      • Test Plans
      • Test Reports
      • Files
      • Software
      • Environments
      • Untitled
      • Executions
      • Favorites
      • Statistics
      • User Management
      • Customer Management
      • Notifications
      • Configurations
      • Invoicing
  • Models
    • Overview
    • Base Model
      • BaseScreen
        • BaseScreen Properties
        • BaseScreen Methods
      • OnScreenElement
        • OnScreenElement Methods
        • OnScreenElement Properties
      • Primitives
        • Button
          • Button Methods
          • Button Properties
        • Checkbox
          • Checkbox Methods
        • ContextMenu
          • ContextMenu Methods
          • ContextMenu Properties
        • Dropdown
          • Dropdown Methods
          • Dropdown Properties
        • DropdownMenu
          • DropdownMenu Methods
          • DropdownMenu Properties
        • GenericScroller
          • GenericScroller Methods
          • GenericScroller Properties
        • HorizontalScroller
        • IconButton
          • IconButton Properties
        • Label
        • LabelWithButton
          • LabelWithButton Properties
        • LabelWithCheckbox
          • LabelWithCheckbox Properties
        • LabelWithValue
          • LabelWithValue Methods
          • LabelWithValue Properties
        • PwTextBox
          • PwTextBox Methods
        • TextBox
          • TextBox Methods
          • TextBox Properties
        • Tables and lists
          • Column
            • Column Methods
            • Column Properties
          • ItemList
            • ItemList Methods
            • ItemList Properties
          • Row
            • Row Methods
            • Row Properties
          • TableBase
            • TableBase Methods
            • TableBase Properties
        • LabelWithElementBase
          • LabelWithElementBase Properties
      • Enumerations
      • Extensions
        • EngineResultExtensions Methods
        • EnumExtensions Methods
        • ReportExtensions Methods
        • StringExtensions Methods
        • TesterConnectionExtensions Methods
        • TesterDebugExtensions Methods
        • TesterHelperExtensions Methods
        • TesterMouseExtensions Methods
        • TesterOnScreenElementExtensions
        • TesterSelectExtensions Methods
      • Helper Classes
        • BaseModelHelpers
          • BaseModelHelpers Methods
          • BaseModelHelpers Properties
        • Attributes for Designer
        • ListHelpers
      • Exceptions
        • ElementNotFoundException
        • InteractionFailedException
        • ScreenNotFoundException
      • Interfaces
        • IAppBasics Interface
          • IAppBasics Methods
          • IAppBasics Properties
        • IBrowser
        • ICommandLineWindow
        • IScroller Interface
          • IScroller Methods
          • IScroller Properties
        • ISutLocale Interface
          • ISutLocale Methods
          • ISutLocale Properties
        • ISystemHelpers
        • ISystemInteractions
        • IWindow
    • Environment Model
      • Windows
        • Screens
          • CmdWindow
            • CmdWindow Methods
            • CmdWindow Properties
          • FileDialog
            • FileDialog Methods
            • FileDialog Properties
          • FileExplorer
            • FileExplorer Properties
          • RunWindow
            • RunWindow Methods
            • RunWindow Properties
          • Window
            • Window Methods
            • Window Properties
        • SutLocale
          • SutLocale Methods
          • SutLocale Properties
        • SystemHelpers
          • SystemHelpers Methods
          • SystemHelpers Properties
        • SystemInteractions
        • WebBrowser
          • Browser
            • Browser Methods
            • Browser Properties
          • BrowserScroller
            • BrowserScroller Methods
            • BrowserScroller Properties
          • AuthenticationDialog
            • AuthenticationDialog Methods
            • AuthenticationDialog Properties
          • DownloadDialog
            • DownloadDialog Methods
            • DownloadDialog Properties
        • EnvironmentModel Enumerations
        • Interfaces
          • IWebAppBasics
            • IWebAppBasics Property
Powered by GitBook
On this page
  • Visual verification
  • Verificiation by parsing the PDF File
  • Access the pdf file from the Execution Host
  • Parsing the pdf File
  • Verifying the pdf Content

Was this helpful?

  1. Designer
  2. FAQ

Verify PDF Content

PreviousUsing Excel as test data sourceNextOverview

Last updated 1 year ago

Was this helpful?

Visual verification

To verify the rendering and for example images in a pdf, we recommend using visual verification. You can model the PDF content as a Screen and use Screen Elements like and .

Verificiation by parsing the PDF File

To verify large text content, it is recommended to parse the PDF file into a C# object and verify the content directly in code.

An example TestCase is available on Github:

The following chapters guide you through this example.

Access the pdf file from the Execution Host

[TestStep(1, TestInput = "Make pdf file accessible for Execution Host")]
public void Step1(ITester t)
{
    //the goal is to parse the .pdf file with the used iText7 Nuget
    //for that the execution host (where to code is running) needs access to the pdf file
    //the following code copies the file from the System Under Test (SUT) to the Execution host using the RemoteDirectory

    //Make sure the connection string to the RemoteDirectory is correctly set on the Test Environment
    //https://docs.testresults.io/designer/interacting-with-the-sut/tabs-overview/environments#remote-directory-connection-string

    string pdfPath = @"C:\\Temp\\";
    string pdfFileName = "myPdf.pdf";
    App.SystemHelpers.SetUpRemoteDirectory(true);
    App.SystemHelpers.CopyFiles(Path.Combine(pdfPath, pdfFileName), App.SystemHelpers.ArtifactsDirectory);
    var remoteDirectoryOnHost = BaseModelHelpers.MapRemoteDirectoryOnHost(t);
    if (!remoteDirectoryOnHost.Exists || remoteDirectoryOnHost.GetFiles(pdfFileName).Length == 0)
        throw new TestStepAbortedException($"Could not read {pdfFileName} on host from remoteDirectory");

    var _pdfPathOnHost = Path.Combine(remoteDirectoryOnHost.FullName, pdfFileName);
}

Parsing the pdf File

In the example project, we use the iText7 Nuget to help parsing the File.

We also implemented a Helper class for the parsing and verification tasks. Add the references Nuget to your Project and copy this Helper class. As iText7 offers a lot of options you can also extend and modify the Helper class according to your needs.

Verifying the pdf Content

[TestStep(2,
    TestInput = "Verify the content of the pdf",
    ExpectedResults = "The pdf content is as expected")]
public void Step2(ITester t)
{
    var helper = new PdfValidationHelper(t);
    string pdfPath = _pdfPathOnHost ?? "myPdf.pdf"; //the variable set in TestStep 1 should be used, but for demo purposes also the pdf project item works
    var expectedPdfContent = new List<ExpectedPDFContent>() 
    { 
        new ExpectedPDFContent(page: 1, line: 13, "Maecenas mauris lectus, lobortis et purus mattis, blandit dictum tellus."),                     // expected to pass
        new ExpectedPDFContent(page: 1, line: 13, "Maecenas mauris lectus, lobortis et purus mattis, blandit dictum tellus"),                      // expected to fail, missing the . at the end
        new ExpectedPDFContent(page: 3, line: 20, "In non mauris justo. Duis vehicula mi vel mi pretium, a viverra erat efficitur. Cras aliquam"), // expected to fail, text is different
        new ExpectedPDFContent(page: 3, line: 50, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."),   // expected to fail, only 38 lines on page 3
        new ExpectedPDFContent(page: 5, line: 20, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.")    // expected to fail only 4 pages
    };
    helper.ValidatePDFAndReport(pdfPath, expectedPdfContent);
}

To enable parsing, first we need to make sure the Execution Host (where the code is actually running) has access directly to the file. contains an example on how to copy the pdf File from the System Under Test to the Execution host, by using a Network Drive. Make sure to setup the correctly before.

contains the Example on how to verify the pdf Content. In this example you can define which text is expected on each page and line:

TestStep1
Remote Directory Connection String
TestStep2
Labels
Labels with Values
https://github.com/TestResultsIO/DemoAutoScout24/tree/main/TC007_Rev1
Logoitext7 8.0.2nuget
https://github.com/TestResultsIO/DemoAutoScout24/blob/main/TC007_Rev1/PdfValidationHelper.cs