【问题标题】:Python Selenium return text, unicode object is not callablePython Selenium 返回文本,unicode 对象不可调用
【发布时间】:2015-09-05 17:48:29
【问题描述】:

我正在尝试使用 Selenium 来自动化一些网页浏览。目前我正在尝试通过类名访问特定元素并返回其中的文本(我在页面上选择的元素肯定有文本),当我尝试在我的函数中返回它时,我得到了

TypeError: 'unicode' object is not callable

我的函数代码如下:

driver = webdriver.Chrome("my chromedriver installation path")
driver.get("website URL")

def getText():
    return driver.find_element_by_class_name("class with text").text()

print getText()

【问题讨论】:

    标签: python python-2.7 selenium typeerror selenium-chromedriver


    【解决方案1】:

    .text不是方法,是属性:

    driver.find_element_by_class_name("class with text").text
    

    【讨论】:

      猜你喜欢
      • 2017-02-05
      • 2014-12-08
      • 2012-07-29
      • 2017-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多