I am stuck at one end, I am not able to get values.
For better view... I need to get these values
1)809
<td id="tdResultSpFlights" onclick="consultaSpFlights(809,1);" style="cursor:pointer;"><u>809</u></td>
2)2
<td id="tdResultSpCanceledFlights" onclick="consultaSpCanceledFlights(2,1);" style="cursor:pointer;"><u>2</u></td>
3)90
<td id="tdResultSpDelayedFlights" onclick="consultaSpDelayedFlights(90,1);" style="cursor:pointer;"><u>90</u></td>
If I use
find_element(By.TAG_NAME,"u")
Applying with the first one is correct, but i cannot get the others, due to they has the same tag name. I already try with xpath, class and id. How can i get values above?
CodePudding user response:
find_element()
will return the first matching element. Instead you need to use find_elements()
and to extract the texts you can use a list comprehension as follows:
print([my_elem.text for my_elem in driver.find_elements(By.TAG_NAME, "u")])