Rayrun
← Back to videos

Playwright (NODEJS) Reading and Writing to a CSV

Using Playwright and some third party package support, learn how to read from CSV files and also write to a new CSV.

In this video tutorial, the presenter, Jared from 'Commit to Quality' illustrates how to read and write from and to CSV files using 'Playwright' and the 'Fast CSV' node package.

In the walkthrough, he implements the 'Fast CSV' package in Playwright, starting by showing how it is done directly inside the test. Firstly, he demonstrated how to install the 'Fast CSV', the setup involved in creating a CSV file and how to read the documentation to grasp the implementation and format of the package. Next, he created a promise inside the test, to return a JavaScript array which transforms the CSV into a JSON file.

He showcased how to use the 'Fast CSV' parsing part of the node module after installation by importing it as CSV. He mentioned the importance of transforming the JsonObject array and setting up a rows array for the created object. He also included how to create listeners to facilitate work with the promise, setting up a critical callback and creating new arrays when needed.

Interestingly, he explained how setting headers to true transforms every row into a JavaScript object array while doing otherwise stores all data as arrays. He further taught how to write into a new CSV, where he created a new array from the CSV file, added a new column header to it, and added more data to it using the 'unshift' method in JavaScript.

Towards the end of the video, he detailed how to implement the 'Write' method in Fast CSV while wrapping up his tutorial by reiterating the easy nature of reading and writing from CSV's in Playwright using the Fast CSV parser, noting that it can be extended to any other test automation framework.

Overall, this comprehensive tutorial provides detailed hands-on learning for users looking to understand and implement data handling with CSV files using Playwright and the Fast CSV node package.

Related Videos

#16 - ARIA and how Playwright is making use of it to identify UI controls?
#16 - ARIA and how Playwright is making use of it to identify UI controls?
Playwright Tutorial - (NODEJS) Get Test Information during test execution
Playwright Tutorial - (NODEJS) Get Test Information during test execution
Create feature, steps & config | Playwright & Cucumber - Typescript | Part 1
Create feature, steps & config | Playwright & Cucumber - Typescript | Part 1
Playwright Working with Multiple tabs (NODEJS)
Playwright Working with Multiple tabs (NODEJS)
TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.