Skip to content

Commit

Permalink
Added StaticTable.spec.js Script
Browse files Browse the repository at this point in the history
  • Loading branch information
NarendraCodeHub committed Jan 16, 2025
1 parent dd2e513 commit 86e35a8
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/Tables/StaticTable.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { test, expect } = require('@playwright/test');

test('Validate table data in People Table', async ({ page }) => {
const targetUrl = 'https://qa-practice.netlify.app/web-table';
const tableSelector = '#peopleTable';
const rowsSelector = `${tableSelector} tbody tr`;

await page.goto(targetUrl);

// Wait for the table rows to load and be visible
await page.waitForSelector(rowsSelector, { state: 'visible' });

// Validate the number of rows in the table
const rows = page.locator(rowsSelector);
await expect(rows).toHaveCount(5); // Verify there are 5 rows

// Validate specific cell data in the table
const firstRow = rows.nth(0);
await expect(firstRow.locator('td:nth-child(2)')).toHaveText('Mark');
await expect(firstRow.locator('td:nth-child(3)')).toHaveText('Otto');
await expect(firstRow.locator('td:nth-child(4)')).toHaveText('[email protected]');

const secondRow = rows.nth(1);
await expect(secondRow.locator('td:nth-child(2)')).toHaveText('Jacob');
await expect(secondRow.locator('td:nth-child(3)')).toHaveText('Thornton');
await expect(secondRow.locator('td:nth-child(4)')).toHaveText('[email protected]');

const thirdRow = rows.nth(2);
await expect(thirdRow.locator('td:nth-child(2)')).toHaveText('Larry');
await expect(thirdRow.locator('td:nth-child(3)')).toHaveText('Bow');
await expect(thirdRow.locator('td:nth-child(4)')).toHaveText('[email protected]');

const fourthRow = rows.nth(3);
await expect(fourthRow.locator('td:nth-child(2)')).toHaveText('Bobby');
await expect(fourthRow.locator('td:nth-child(3)')).toHaveText('Spencer');
await expect(fourthRow.locator('td:nth-child(4)')).toHaveText('[email protected]');

const fifthRow = rows.nth(4);
await expect(fifthRow.locator('td:nth-child(2)')).toHaveText('Mark');
await expect(fifthRow.locator('td:nth-child(3)')).toHaveText('Icarus');
await expect(fifthRow.locator('td:nth-child(4)')).toHaveText('[email protected]');

});

0 comments on commit 86e35a8

Please sign in to comment.