Force Chromium to download PDFs

Hello,

I am in the process of rewriting Selenium Library to Browser Library and hit a challenge. The site I am testing creates a dynamically generated PDF. In Selenium with Firefox I disable showing PDF files in the browser which triggers the browser to download the PDF on which I later run a compare validation process on.

In the Browser Library I have not had any luck finding how to disable the PDF viewing and force the PDF to be downloaded in Chromium.

Any suggestions on how to achieve this?

Thanks for your help,
Lowres.

There seems to be an issue with Playwright that causes this: [Feature] Make PDF testing idiomatic · Issue #7822 · microsoft/playwright · GitHub. There alse a Python workaround posted in this thread that you can perhaps use?

Thanks Falcon030,

So worked it out in the end I found a button in the UI which triggers a download of the PDF(phew) I launch my browser with:

New Persistent Context    url=${CLOUDINSTANCEURL}    browser=${BROWSER} headless=${HEADLESS}    acceptDownloads=true

And the part in my script where the download happens is…

${dl_promise}          Promise To Wait For Download    ${DOWNLOADDIR}\\${PNLNAME}.pdf
Click    //td[text()="Download as PDF"]
${file_obj}=           Wait For    ${dl_promise}