【发布时间】:2014-03-06 16:58:53
【问题描述】:
我想访问标签的文本,但 get_text() 和 text 属性都不适用于以下 HTML:
<label class="checkbox">
<input type="checkbox" value="BATSMC">
BATS Multicast PITCH
</label>
比如这里我要获取值:BATS Multicast PITCH。
在 Selenium-Python 代码中:
print e.text
给出空格,get_text() 给出以下错误:
AttributeError: 'WebElement' object has no attribute 'get_text'
我得到了正确的网络元素,并且能够访问其他属性,如大小、位置、父级等。我希望“文本”能够工作。任何人都可以帮忙吗?
【问题讨论】:
标签: python python-2.7 selenium-webdriver