|
| 1 | +const { test, expect } = require('@playwright/test'); |
| 2 | + |
| 3 | +test('Validate Dyamiv Table', async({page})=> { |
| 4 | + // Navigate to the page |
| 5 | + await page.goto('https://qa-practice.netlify.app/dynamic-table'); |
| 6 | + |
| 7 | + // Wait for the table to load |
| 8 | + await page.waitForTimeout(2000); |
| 9 | + await page.waitForSelector('#data-table', { state: 'visible', timeout: 10000 }); |
| 10 | + |
| 11 | + // Get all rows in the table body |
| 12 | + const rows = await page.$$('#data-tbody > tr'); |
| 13 | + |
| 14 | + console.log(`Total rows found: ${rows.length}`); |
| 15 | + |
| 16 | + // Iterate through each row and extract the data |
| 17 | + for (const row of rows) { |
| 18 | + // Get all columns for the current row |
| 19 | + const columns = await row.$$('td'); |
| 20 | + |
| 21 | + // Extract data from each column |
| 22 | + const avatar = await columns[0].$('img'); |
| 23 | + const avatarSrc = await avatar.getAttribute('src'); |
| 24 | + const firstName = await columns[1].textContent(); |
| 25 | + const lastName = await columns[2].textContent(); |
| 26 | + const age = await columns[3].textContent(); |
| 27 | + const email = await columns[4].textContent(); |
| 28 | + const city = await columns[5].textContent(); |
| 29 | + const country = await columns[6].textContent(); |
| 30 | + |
| 31 | + console.log({ |
| 32 | + Avatar: avatarSrc.trim(), |
| 33 | + FirstName: firstName.trim(), |
| 34 | + LastName: lastName.trim(), |
| 35 | + Age: age.trim(), |
| 36 | + Email: email.trim(), |
| 37 | + City: city.trim(), |
| 38 | + Country: country.trim(), |
| 39 | + }); |
| 40 | + } |
| 41 | +}); |
0 commit comments