Skip to content

Commit 86e35a8

Browse files
Added StaticTable.spec.js Script
1 parent dd2e513 commit 86e35a8

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/Tables/StaticTable.spec.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const { test, expect } = require('@playwright/test');
2+
3+
test('Validate table data in People Table', async ({ page }) => {
4+
const targetUrl = 'https://qa-practice.netlify.app/web-table';
5+
const tableSelector = '#peopleTable';
6+
const rowsSelector = `${tableSelector} tbody tr`;
7+
8+
await page.goto(targetUrl);
9+
10+
// Wait for the table rows to load and be visible
11+
await page.waitForSelector(rowsSelector, { state: 'visible' });
12+
13+
// Validate the number of rows in the table
14+
const rows = page.locator(rowsSelector);
15+
await expect(rows).toHaveCount(5); // Verify there are 5 rows
16+
17+
// Validate specific cell data in the table
18+
const firstRow = rows.nth(0);
19+
await expect(firstRow.locator('td:nth-child(2)')).toHaveText('Mark');
20+
await expect(firstRow.locator('td:nth-child(3)')).toHaveText('Otto');
21+
await expect(firstRow.locator('td:nth-child(4)')).toHaveText('mo@email.com');
22+
23+
const secondRow = rows.nth(1);
24+
await expect(secondRow.locator('td:nth-child(2)')).toHaveText('Jacob');
25+
await expect(secondRow.locator('td:nth-child(3)')).toHaveText('Thornton');
26+
await expect(secondRow.locator('td:nth-child(4)')).toHaveText('jacob_t@yahoo.com');
27+
28+
const thirdRow = rows.nth(2);
29+
await expect(thirdRow.locator('td:nth-child(2)')).toHaveText('Larry');
30+
await expect(thirdRow.locator('td:nth-child(3)')).toHaveText('Bow');
31+
await expect(thirdRow.locator('td:nth-child(4)')).toHaveText('lbow@gmail.com');
32+
33+
const fourthRow = rows.nth(3);
34+
await expect(fourthRow.locator('td:nth-child(2)')).toHaveText('Bobby');
35+
await expect(fourthRow.locator('td:nth-child(3)')).toHaveText('Spencer');
36+
await expect(fourthRow.locator('td:nth-child(4)')).toHaveText('bobby_23@gmail.com');
37+
38+
const fifthRow = rows.nth(4);
39+
await expect(fifthRow.locator('td:nth-child(2)')).toHaveText('Mark');
40+
await expect(fifthRow.locator('td:nth-child(3)')).toHaveText('Icarus');
41+
await expect(fifthRow.locator('td:nth-child(4)')).toHaveText('el_icarus@yahoo.com');
42+
43+
});

0 commit comments

Comments
 (0)