To check if a PDF file has been downloaded using Robot Framework, you can follow these steps:
Make sure you have:
The SeleniumLibrary installed (for browser automation).
A known download directory where the browser saves files.
Set the download directory in your browser configuration.
Click the button to trigger the download.
Wait for the file to appear in the download directory.
Verify the file exists and optionally check its name or type.
YAML
*** Settings ***
Library SeleniumLibrary
Library OperatingSystem
*** Variables ***
${DOWNLOAD_DIR} /path/to/downloads
${EXPECTED_FILE} downloaded_file.pdf
*** Test Cases ***
Check PDF Download
Open Browser https://your-site.com chrome
Set Download Directory ${DOWNLOAD_DIR}
Click Button id=download-button
Wait Until File Exists ${DOWNLOAD_DIR}/${EXPECTED_FILE} timeout=30s
File Should Exist ${DOWNLOAD_DIR}/${EXPECTED_FILE}
[Teardown] Close Browser
*** Keywords ***
Set Download Directory
[Arguments] ${dir}
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${options} add_experimental_option prefs {'download.default_directory': '${dir}'}
Create WebDriver Chrome chrome_options=${options}
Show less
Code block expanded