We have a web table with price and item list, we have to get each item's price and calculate the total. Let's see how to do it using #playwright
This blog post describes the contents of a video tutorial on handling table calculations in web scraping. The video tutorial starts by explaining the scenario of adding up prices in a table and checking if the total is correct. The tutorial then proceeds to demonstrate how to find the table body and footer using CSS locators. The number of rows and columns in the table are determined using a loop.
To calculate the total price, a loop is used to iterate through each row of the table. The text content of the last column in each row, which represents the price, is retrieved and converted to a number using the Number constructor. The total price is then calculated by adding the prices together.
Finally, an assertion is made to check if the calculated total matches the actual total displayed in the footer. The actual total is retrieved using a CSS locator and converted to a number using the Number constructor.
The blog post reiterates the steps taken in the video tutorial and summarizes the key concepts and techniques used. It also mentions that in the next video, the tutorial will cover how to handle sorting and pagination in tables during web scraping.
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].