首页 > 解决方案 > 使用 Selenium Python 时如何从 td 标签获取文本值?

问题描述

html 看起来像:

<tbody>
    <td>
      content
    </td>
</tbody>

我已经通过 find_element_by_xpath 函数找到了元素 td。但是我什至只得到没有内容的字符串,但实际上网络显示了内容。

代码喜欢: driver.find_element_by_xpath('//tbody/td').text

标签: pythonselenium-chromedriver

解决方案


您可以使用:

.get_attribute('innerText')

推荐阅读