【问题标题】:TypeError: 'module' object is not callable error with ChromeDriver and Chrome using Selenium on macosTypeError: ‘module’ object is not callable error with ChromeDriver and Chrome using Selenium on macos
【发布时间】:2020-07-18 07:38:48
【问题描述】:

当我尝试测试我的测试应用程序以查看 Selenium Chrome 是否正常工作时,我收到此错误:

driver= webdriver.chrome("/usr/local/bin/chromedriver")
 TypeError: 'module' object is not callable

我检查了是否安装

/usr/local/bin/chromedriver --version
ChromeDriver 84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310})

但即使重新启动我的计算机,我仍然会收到错误。

我的环境是:

  • Mac OS Catalina (10.15.6)
  • Chrome 版本:84.0.4147.89
  • PyCharm 专业版

怎么了?

【问题讨论】:

    标签: python selenium google-chrome selenium-chromedriver typeerror


    【解决方案1】:

    webdriver.Chrome 类区分大小写。现在,您收到此错误是因为您无意中尝试调用模块 webdriver.chrome

    如果您将代码更改为

    driver = webdriver.Chrome("/usr/local/bin/chromedriver") 
    

    您应该不再收到此错误。

    【讨论】:

      【解决方案2】:

      此错误消息...

      TypeError: 'module' object is not callable
      

      ...暗示有一个 调用chrome 模块。


      根据您使用的代码尝试:

      driver= webdriver.chrome()
      

      这里chrome 解释为webdriver 的子模块:


      解决方案

      相反,您需要调用selenium.webdriver.chrome.webdriver 类方法,如下所示,最好使用key executable_path,如下所示:

      driver= webdriver.Chrome(executable_path='/usr/local/bin/chromedriver')
                        ^ note the uppercase C
      

      【讨论】:

        【解决方案3】:

        driver= webdriver.chrome("/usr/local/bin/chromedriver")

        这应该是 driver= webdriver。Chrome("/usr/local/bin/chromedriver")

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2020-03-27
          • 2021-04-21
          • 2018-12-17
          • 2018-09-15
          • 2018-03-31
          • 2022-12-26
          相关资源
          最近更新 更多