I am getting the cells of a table this way with Selenium. What I'm getting is a list with the value of each cell.
def seleccionar_productos(driver):
rows = driver.find_elements_by_xpath("//table[@id='tabla']/tbody/tr")
cells = driver.find_elements_by_xpath("//table[@id='tabla']/tbody/tr/td")
column_count = len(cells)/len(rows)
print ("filas=%s columnas=%s" % (row_count, column_count) )
print( cells[0].get_attribute('innerHTML'))
print( rows[0].get_attribute('innerHTML'))
I would like to be able to get the same thing but in the form of a matrix because it is easier to manage
The result of this is:
filas=10 columnas=14.0
The value of cells[0].get_attribute('innerHTML')
gives me the value of the cell (Great).
But the value of rows[0].get_attribute('innerHTML')
is intratable, something like that.
<td>Text1</td> <td>Text2</td> <td>Text3</td> <td>Text4</td> <td>Text4</td>....
The cells variable has values from 0 to 140
And I wish I could have it this way
cells[coll][row].get_attribute('innerHTML')
Where Coll will have values between 0 and 14, and row between 0 and 10
And if not some way to extract the values of the variable "rows".
Any questions?