26. Dynamic Data Tables & Pagination Automation

Parsing Web Tables in Python

rows = driver.find_elements(By.XPATH, "//table[@id='orders']//tbody/tr")

for row in rows:
cells = row.find_elements(By.TAG_NAME, "td")
order_id = cells[0].text
status = cells[1].text
if status == "PENDING":
row.find_element(By.XPATH, ".//button[text()='Approve']").click()
break

Task

  • Implement count_table_rows(driver, table_xpath):
  • 1. Locate rows via By.XPATH f"{table_xpath}//tbody/tr".
  • 2. Return len(rows).
πŸ’‘Common doubts
Did you like the problem?
Lesson 26 of 43
Python
Loading code editor…
Next