1
Get the download button locator
In order to handle the download, you will need a locator for the button that downloads the file. You can get this locator by recording clicking or hovering on the button, which will create an action in the step list. Double click on the element name inside the generated action, and copy the locator.

2
Add download handling code
Create a new code block and add the following code, replacing the locator with the one you just found, and changing the variable name of the downloaded file to your liking.Method 2: Fetch from URL
If you have more than one tab open, you will need to change
page
to the name of the page with the download button, eg. page2
PDF Files
Method 1: Download from pageExcel Files

The modified code using my locator
Office Documents (DOCX, PPTX)
This method parses Office documents and returns plain text. For Excel files, use the XLSX package above to preserve formatting and structure.
As shown above, if you want to verify the filename of the downloaded file, you can access it like this:
download.suggestedFilename();
CSV Files
3
Add AI assertion
Add an AI assertion that references the variable name from the code block to verify the contents of the downloaded file.
You can use the ‘Disabled’ screenshot type to force the AI to only look at the available variables, and not the page.

A sample assertion
4
Run the test
Run the test to the end. As you can see, the AI was able to verify the contents of the Excel file.

5
Clean up
Delete or skip the first action you added to get the locator.