). The value I would lile to print out is in the inside a
Solution 1:
The developer has put an ID into the table. I have it working now. It is printing all the cell values from column 2. The code is:
table_id = self.driver.find_element(By.ID, 'data_configuration_feeds_ct_fields_body0')
rows= table_id.find_elements(By.TAG_NAME, "tr") # getallof the rowsin the tableforrowinrows:
# Get the columns (all the column2)
col = row.find_elements(By.TAG_NAME, "td")[1] #note: index startfrom0, 1is col 2
print col.text #prints text from the element
Solution 2:
The XPath you currently using is quite fragile since it depends on the complete document structure and the relative position of the elements. It can easily break in the future.
Instead, locate the rows using their class or other attributes. For instance:
for row in driver.find_elements_by_css_selector("tr.GAT4PNUFG.GAT4PNUMG"):
cell = row.find_elements_by_tag_name("td")[1]
print(cell.text)
Share
Post a Comment
for "Iterate Through Table Rows And Print Column Text With Python Selenium"
Post a Comment for "Iterate Through Table Rows And Print Column Text With Python Selenium"