Test Automation Stack

In playwright we can launch browser in two ways:
1. Just import the Page from @playwright/test lib
2. Create your own browser instance and pass the download path(Other launch options too)

By default Playwright creates a temp folder and downloads the files to that folder and deletes after execution.

If one needs to assert on the file downloaded and also to read and perform operation, its hard to keep that file in temp folder.

So the way to handle this would be store the file to a custom folder and then using Download API, save the file with actual name(As playwright downloads the file with random GUID)

Below code snippet shows how to achieve this and also uses Chai-Files assertion library to check for the existence of the file

Leave a comment

I’m Gurudatt

Profile Pic

With over 12 years of quality assurance experience, i have used various test automation tools and testing concepts and helped organization and teams to speed up testing process effectively. I’m also a Cypress.io Ambassador and BrowserStack Champion.

Let’s connect

Discover more from Test Automation Stack

Subscribe now to keep reading and get access to the full archive.

Continue reading