python selenium - 打印xpath值

use*_*332 2 python selenium

这是我的代码:

print browser.find_element_by_xpath('/html/body/div[2]/div/div/div/h1/div/small')
Run Code Online (Sandbox Code Playgroud)

它打印<selenium.webdriver.remote.webelement.WebElement object at 0x02915310> 但我希望它打印实际值,这将是0.00

有任何想法吗?

Ric*_*ard 7

这适用于内部文本:

print browser.find_element_by_xpath('/html/body/div[2]/div/div/div/h1/div/small').text
Run Code Online (Sandbox Code Playgroud)

或者,如果您想获得价值:

print browser.find_element_by_xpath('/html/body/div[2]/div/div/div/h1/div/small').get_attribute("value");
Run Code Online (Sandbox Code Playgroud)