I'm trying to get the value between the div, as I am trying to continue the program once the code has been introduced correctly. However I can't seem to get the value from the element. Value is in this case '12345678'
<td id="TransaccionTesoreriaRetencionItems_NroComprobanteRetencion_1" height="22px">
<div style="width: 115px; overflow: hidden; cursor: pointer;">
12345678
</div>
</td>
CodePudding user response:
- get the td
let a = document.getElementById("TransaccionTesoreriaRetencionItems_NroComprobanteRetencion_1")
- get the divs inside the td
let b = a.getElementsByTagName("div")
- get the first div inside the list
let c = b[0].innerText
and you get
c
'12345678 '
CodePudding user response:
To print the text 12345678 you can use either of the following locator strategies:
Using css_selector:
print(driver.find_element(By.CSS_SELECTOR, "td#TransaccionTesoreriaRetencionItems_NroComprobanteRetencion_1 > div").text)
Using xpath:
print(driver.find_element(By.XPATH, "//td[@id='TransaccionTesoreriaRetencionItems_NroComprobanteRetencion_1']/div").text)