Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value from HTML TD Between Div

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&nbsp;&nbsp;&nbsp;
    </div>
</td>

Code image

like image 781
Feso Avatar asked Jun 06 '26 20:06

Feso


1 Answers

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)
    
like image 165
undetected Selenium Avatar answered Jun 09 '26 11:06

undetected Selenium



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!