I am trying to get the tag text content in html page by using Selenium methods, but it seems method someElement.getText()
is not available in Python. Any help, please?
我正在尝试使用Selenium方法在html页面中获取标记文本内容,但是在Python中似乎无法使用method someElement.getText()。任何帮助吗?
Here's traceback:
回溯:
AttributeError: 'WebElement' object has no attribute 'getText'
1 个解决方案
#1
26
Once you locate the element you can use the text method.
一旦找到元素,就可以使用text方法。
Example:
例子:
for element in self.driver.find_elements_by_tag_name('img'):
print element.text
print element.tag_name
print element.parent
print element.location
print element.size
#1
26
Once you locate the element you can use the text method.
一旦找到元素,就可以使用text方法。
Example:
例子:
for element in self.driver.find_elements_by_tag_name('img'):
print element.text
print element.tag_name
print element.parent
print element.location
print element.size