elements / tables
Advanced element
Tables
Sortable and filterable data tables, column headers with ascending/descending order, cell extraction, and row checkbox selection.
Sortable & filterable table
#table-data
Click headers to sort ascending / descending
| Name ↕ | Role ↕ | Status ↕ | Score ↕ |
|---|---|---|---|
| Aarav Patel | SDET Lead | Active | 94 |
| Sara Connor | QA Automation | Active | 88 |
| Liam Smith | Manual QA | Inactive | 65 |
| Priya Nair | Security Tester | Active | 97 |
| Elena Rostova | Performance QA | Pending | 78 |
| Carlos Mendes | DevOps Engineer | Active | 84 |
| Zack Taylor | SDET Junior | Pending | 71 |
| Maya Lin | QA Architect | Active | 99 |
- table
- #table-data
- search
- #table-search
- columns
- name, role, status, score
- expected
- Clicking column headers toggles sort; search input filters table rows dynamically.
Code snippets
Python (Selenium)
# Filter table
driver.find_element(By.ID, "table-search").send_keys("Sara")
visible_rows = [r for r in driver.find_elements(By.CSS_SELECTOR, "#table-data tbody tr") if r.is_displayed()]
assert len(visible_rows) == 1
assert "Sara Connor" in visible_rows[0].text
# Sort by Score
driver.find_element(By.ID, "th-score").click()TypeScript (Playwright)
await page.fill('#table-search', 'Sara');
const rows = page.locator('#table-data tbody tr:visible');
await expect(rows).toHaveCount(1);
expect(await rows.first().textContent()).toContain('Sara Connor');
// Click header to sort
await page.click('#th-score');Row selection table
#table-select
0 rows selected
| Select | Task | Severity |
|---|---|---|
| Validate login session persistence | High | |
| Verify payment gateway redirect | Critical | |
| Check header alignment on mobile | Low | |
| Assert CSV report download payload | Medium |
- table
- #table-select
- checkboxes
- #row-chk-1..4
- counter
- #selected-count
- expected
- Checking row boxes updates total selected counter.
Code snippets
Python (Selenium)
driver.find_element(By.ID, "row-chk-1").click()
driver.find_element(By.ID, "row-chk-2").click()
count = driver.find_element(By.ID, "selected-count").text
assert "2 rows selected" in countTypeScript (Playwright)
await page.check('#row-chk-1');
await page.check('#row-chk-2');
expect(await page.textContent('#selected-count')).toContain('2 rows selected');