# Validate PDF File

PDF files are commonly used for generating reports and documents across different business areas and companies. Test Studio, as being among the PDF automation tools, provides the functionality for **PDF validation automation** out-of-the-box and completely codeless.

Find out how to open a PDF file in the browser and record the scenario actions in a Test Studio test.

<CtaPanelIntroduction></CtaPanelIntroduction>

## Enable Edge Browser for PDF Validation

Windows OS default settings use Edge browser as a PDF viewer. As long as this is set that way, Test Studio automation logic fails to save the downloaded PDF file and open it in new tab.

To be able to **use the PDF validation with Edge browser**, you need to **change the Windows OS default PDF viewer** and choose another app to open PDF documents.

![Set default pdf viewer](https://www.telerik.com/teststudio/documentation/assets/7ab66e7436520e32a6ea0c9156dd4a5f/set-default-pdf-viewer.png)

## Download and Open PDF File

Usually when working with data exported to PDF file, you need to generate the specific content and download the PDF file, then open it and validate if the expected information is listed in the generated file.

And this is a complete end-to-end scenario for test automation of a PDF file in a Test Studio recording session. Whenever a **PDF file is downloaded**, the recording process detects it and **opens it in a new tab of the recording browser**. As a result, there is a sequence of steps recorded - click the download button, handle the download dialog, open the downloaded PDF, connect to the tab with PDF file opened, record different type of steps to check the content and automate the PDF validation.

![Steps recorded automatically for test automation pdf](https://www.telerik.com/teststudio/documentation/assets/fa29fc4678c9c0246da4d5c3f352197c/fig1.png)

## Open Local PDF File

Another scenario for PDF test automation is to **open an existing locally stored file** and validate its content. To accomplish this in a Test Studio test, you can use the <a href="/features/custom-steps/open-pdf" target="_blank">**Open PDF File** step</a> from the Step Builder. Insert a valid path to an existing PDF file to open it during the test execution.

![Add Open pdf step in test from step builder](https://www.telerik.com/teststudio/documentation/assets/1e91eea826c043c91b9205089a192c78/fig2.png)

To open the listed PDF file in the browser and **continue recording**, choose the <a href="/features/test-maintenance/test-step-context-menu" target="_blank">step context menu</a> option **'Open PDF'**. Choose the browser to use and continue the recording session.

![Open pdf from step context menu in test from step builder](https://www.telerik.com/teststudio/documentation/assets/c9bfb1d1373596ef877be38c071c0899/fig2a.png)

> **Note**
>
> Open PDF step is not supported in Internet Explorer.

Once the PDF file is opened in the selected browser recording session, Test Studio recorder captures a **Connect to popup window** step with the localhost address for the PDF file in the test and you can continue recording.

![Open pdf from step context menu in test from step builder](https://www.telerik.com/teststudio/documentation/assets/ca35683af9efe6fd3d9ca66c83172cf9/fig2b.png)

> **Tip**
> <br>
> <br>
> If you have added the **Open PDF** step without active recording session you can also **record the next steps** using the <a href="/automated-tests/test-execution/partial-test-execution" target="_blank"> partial execution options for the test</a>.

## Control What Is Visible from the PDF File

When a PDF file is opened in active recording session, the **toolbar to control the PDF visible part is rendered in the page** and Test Studio recorder has free access to it.

![pdf control toolbar](https://www.telerik.com/teststudio/documentation/assets/99030d8dff1125616190e556e1e1f2fb/fig3.png)

This means you can **add steps to zoom in/out, change the displayed page of the document, set the zoom level from the dropdown, verify the value of the current set zoom level**, etc.

![steps recorded against the pdf control toolbar](https://www.telerik.com/teststudio/documentation/assets/38b08a17356b338c27c271057ef11088/fig4.png)

> **Tip**
> <br>
> <br>
> If you are using a **multiple page PDF document, ensure that the correct page is displayed** before validating its content - you can go to exact page using the *Page* input field.

## Record Steps Against the PDF File

As a PDF validation automation tool Test Studio allows you to add different **verification steps**, which will help in validating the content of the file and, optionally, reuse it later in the test automation actions.

* <a href="/features/recorder/advanced-recording-tools/element-steps/verifications/quick-verification" target="_blank">Quick Verification</a>/ <a href="/features/recorder/advanced-recording-tools/element-steps/verifications/wait" target="_blank">Wait Steps</a>
* <a href="/features/recorder/advanced-recording-tools/element-steps/verifications/advanced-verification" target="_blank">Advanced Verification</a>
* <a href="/features/recorder/advanced-recording-tools/element-steps/verifications/extraction" target="_blank">Extract Text</a>
* <a href="/features/recorder/advanced-recording-tools/element-steps/verifications/text-from-image" target="_blank">Extract Text from Image</a>
* <a href="/features/recorder/advanced-recording-tools/element-steps/verifications/image-verification" target="_blank">Verify Image</a>

## Compare PDF Files

Comparing the content of two PDF files is not a straight-forward scenario, but combining the Test Studio features allows you to automate even such difficult task. Here are the steps for example scenario:

1. Navigate to the tested page.
2. Generate and download the PDF file.
3. Once opened, validate its title and date of creation, for example. (Let's use a report as baseline for the example)
4. Store these values in extracted variables using the <a href="/features/recorder/advanced-recording-tools/element-steps/verifications/extraction" target="_blank">Extraction step</a>.
5. Close the PDF.
6. <a href="/features/custom-steps/open-pdf" target="_blank">Add a step</a> to open the other already existing PDF report.
7. Add the verification steps to validate its title and the date of creation.
8. Close the PDF.
9. Data drive these verification steps using the extracted variables from the downloaded file.
10. Execute the test and it will use the values extracted from the downloaded file to verify if this is the same with the content of the existing PDF file.

## See also

*
