Playwright
  • Introduction
    • Playwright With TS
  • Automation the right things with Playwright
  • Setup
    • Setting Up Your Environment
    • Typescript fundamental
    • Setup Playwright TS Project in VS code
    • Record and Playback with Code Generation using VS Code Playwright Extension
    • Record and Playback using Playwright Codegen with Inspector
  • Playwright config file
  • Implement Test Cases
    • Open Browser
    • Fake Geolocation
    • Form Authentication
    • Checkboxes
    • Dropdown
    • Hyperlink
    • Web Table
    • Drag Drop
    • Frame
    • Horizontal Slide
    • Context Click - Right Click
  • Hover
  • Take Screenshot
  • Automatic screenshots on failure:
  • Page Object Model
    • Understanding the Page Object Model pattern
  • Implementing POM with Login Page
  • Combine POM with Playwright Fixture
  • API Testing
    • API Docs
  • GET
  • API POST
  • PUT
  • DELETE
  • CI/CD And Reporting
    • Setup Allure Report
    • Run in Github Actions
  • Playwright & AI
    • Debug & Generate Playwright Tests with AI
Powered by GitBook
On this page
  1. Implement Test Cases

Web Table

Table

import {test, expect} from '@playwright/test';

test('verify max due person full name', async ({ page }) => {
    await page.goto('https://the-internet.herokuapp.com/tables');
    const table = await page.locator('#table1');
    const rows = await table.locator('tbody tr');

    const tableData = await rows.evaluateAll((rows) => {
        return rows.map((row) => {
            const cells = row.querySelectorAll('td');
            return {
                firstName: cells[0].innerText,
                lastName: cells[1].innerText,       
                due: cells[3].innerText.replace('$', ''),
            };
        });
    });
    const {firstName, lastName} = tableData.reduce((prev, current) => {
        return parseFloat(prev.due) > parseFloat(current.due) ? prev : current;
    });
    expect(`${firstName} ${lastName}`).toBe('Doe Jason');
   })
PreviousHyperlinkNextDrag Drop

Last updated 15 days ago