I have a page on which there is a download link. In my test i want to click on the link and download the file. I am running the test on chrome and whenever i click on the link using playwright instead of download the pdf document is displayed in chromium’s internal pdf viewer. I looked at multiple similar issues mentioned on playwright git repo but none of them seems to be working. Has anyone implemented the pdf download step in any of the test cases?
This thread is trying to answer question "How can I download a PDF using Playwright when the PDF opens in Chromium's internal viewer instead of downloading?"
Yes… i did it in config file as mentioned here
https://playwright.dev/docs/api/class-testoptions#test-options-accept-downloads
You could do something similar to this -
href = page.locator("a.download-pdf").get_attribute('href')
absolute_url = f"https://arxiv.org{href}"
# Download the file using requests
file = requests.get(absolute_url)
with open('output.pdf', 'wb') as f:
f.write(file.content)
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].