Iterate through table in Selenium 2 WebDriver (python)
html-table, python, selenium, selenium-webdriver
Solution
Used:
from selenium.webdriver.common.by import By
trs = driver.find_elements(By.TAG_NAME, "tr")
tds = trs[1].find_elements(By.TAG_NAME, "td")
This allows looping through each one to do as desired.
Problem
I have the following table layout in HTML (which changes accordingly): ``` <table class="other-table-style"> <tr> <th>First Name</th> <th>Last Name</th> <th>Age</th> </tr> <tr> <td align="center" width="30%">Joe</td> <td align="center" width="30%">Bloggs</td> <td align="center" width="40%">28</td> </tr> <tr> <td align="center" width="30%">John</td> <td align="center" width="30%">Doe</td> <td align="center" width="40%">30</td> </tr> </table> ``` I want to be able to iterate through this using Selenium 2.0 WebDriver, but I have not been able to find any good examples. Any help would be greatly appreciated.