For many applications, testing PDFs is an important step in validating end-to-end user journeys. In mabl, you can automate the validation of PDF files and their contents, including capturing screenshots and validations with natural language prompts.
This article explains how to test PDFs in the mabl Trainer:
Assert on PDF metadata
When you download a PDF, the Trainer automatically adds a download assertion that asserts against the name of the PDF file.
To assert on additional metadata, including file type and file size, click on Edit assertion. Alternatively, click on the edit pencil for the download assertion step.
Dynamic filenames
If your application creates a dynamically generated filename for the PDF every time it’s downloaded, see our advice for working with dynamically generated filenames.
Validate PDF content
There are currently two ways to validate PDF content in the Trainer:
Add a GenAI Assertion
Early access
GenAI Assertions for file downloads are currently available in early access for all mabl customers and trial users via the Labs page: Settings > Labs
Prior to general availability, changes to the feature may be made without notice.
To validate PDF contents with a GenAI Assertion, edit the assertion step for the downloaded PDF in the Trainer. Provide a natural language prompt that describes what you would like to validate. To review file contents, click on View file. When you are ready to test your assertion, click on Test assertion.
When you test the assertion, mabl generates assertion criteria. These criteria are sent with the assertion description to the LLM to provide a consistent set of criteria to evaluate as part of your assertion. If you iterate on the assertion description, mabl updates the assertion criteria to reflect the current state of the description.
When asserting against a PDF download, GenAI Assertions may include both the contents of the downloaded file and a screenshot of the page it was downloaded from. If your assertion involves validating something on the webpage, make sure it is visible in the viewport when the assertion step runs. If needed, you can resize the browser window with a set viewport step to capture the necessary details.
Execution limits
GenAI Assertions are unlimited during training so that you can iterate on your assertion as much as you need. During execution, however, keep in mind the following limitations:
- Limit per test : GenAI Assertions are limited to 30 per test.
- Performance tests: GenAI Assertions will fail when run within the context of a performance test.
Open the mabl PDF viewer
If your mabl subscription includes the advanced content validation add-on, you can also validate contents in the mabl PDF viewer. When downloading a PDF, click on the Open PDF button in the download prompt:
The Trainer automatically detects that you’ve switched to the mabl PDF viewer and adds a switch context step before the recorded steps. Add assertions on PDF content as needed.
Limitations
When testing PDFs, keep the following limitations in mind:
- The Trainer can only validate PDFs downloaded via interactions in the UI. PDFs returned from HTTP POST requests, either in API steps or API tests, are not supported.
- Editing PDFs, such as filing out a form, is not supported.
If you are testing PDF content in the mabl PDF viewer (the Open PDF option), please note these additional constraints:
- Not supported for tests that run on Safari (WebKit) browsers
- Cannot open PDFs with blob URLs.
These constraints do not apply to PDF validations that use a GenAI Assertion.