简体   繁体   中英

Get value using python selenium

How am I able to extract the value " document sent " from the following html code using python library selenium see code i tried which returns None

print driver.find_element_by_id('errorMessage').get_attribute("value")

html code:

<TABLE>
<TBODY>
<TR>
<TD id=errorMessage>Document sent. </TD>
</TR>
</TBODY>
</TABLE>

Try this:

driver.find_element_by_id("errorMessage").getText();   

OR

driver.find_element_by_id("errorMessage").getAttribute("innerHTML");

Hope this helps..

Try to use below code to get required text:

from selenium.webdriver.support.ui import WebDriverWait as wait

text = wait(driver, 10).until(lambda driver: driver.find_element_by_id("errorMessage").text)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM