简体   繁体   English

TypeError: 'module' object is not callable error with ChromeDriver and Chrome using Selenium on macos

[英]TypeError: 'module' object is not callable error with ChromeDriver and Chrome using Selenium on macos

When I try to test my test application to see if Selenium Chrome is working, I get this error:当我尝试测试我的测试应用程序以查看 Selenium Chrome 是否正常工作时,我收到此错误:

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

I checked if it is installed我检查了它是否已安装

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

But I still get errors even after restarting my computer.但是即使重新启动计算机后我仍然会遇到错误。

My environment is:我的环境是:

  • Mac OS Catalina (10.15.6) Mac 操作系统卡特琳娜 (10.15.6)
  • Chrome version: 84.0.4147.89 Chrome 版本:84.0.4147.89
  • PyCharm Pro PyCharm临

What's going wrong?出了什么问题?

The class webdriver.Chrome is case sensitive. class webdriver.Chrome区分大小写。 Right now, you get this error because you are, inadvertently, trying to call the module webdriver.chrome .现在,您收到此错误是因为您无意中尝试调用模块webdriver.chrome

If you change your code to如果您将代码更改为

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

you should no longer get this error.你不应该再得到这个错误。

This error message...这个错误信息...

TypeError: 'module' object is not callable

...implies that there was a calling the chrome module. ...暗示调用模块时出现类型chrome


As per your code attempt you have used:根据您使用的代码尝试:

driver= webdriver.chrome()

Here interprets chrome as a submodule of webdriver :这里chrome解释为webdriver的子模块:

chrome_module


Solution解决方案

Instead you need to call selenium.webdriver.chrome.webdriver Class method as follows preferably using the key executable_path as follows:相反,您需要调用selenium.webdriver.chrome.webdriver Class 方法,最好使用密钥executable_path如下:

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError: 'module' object is not callable error using ChromeDriver and Chrome and Selenium Python - TypeError: 'module' object is not callable error using ChromeDriver and Chrome and Selenium Python TypeError:使用Selenium ChromeDriver Chrome和Python时,'module'对象无法调用错误 - TypeError: 'module' object is not callable error using Selenium ChromeDriver Chrome with Python 如何解决 TypeError: 'module' object is not callable 错误使用 Selenium 和 ChromeDriver - How to address TypeError: 'module' object is not callable error using Selenium and ChromeDriver (TypeError: 'module' object is not callable) while using chromedriver of selenium - (TypeError: 'module' object is not callable) while using chromedriver of selenium 类型错误:无法通过 Selenium 和 Python 使用 ChromeDriver 调用“模块”对象 - TypeError: 'module' object is not callable using ChromeDriver through Selenium and Python ChromeDriver:TypeError:“模块”object 不可调用 - ChromeDriver: TypeError: 'module' object is not callable 在 chromedriver (Python) 中使用 Selenium 时对象不可调用错误 - Object not callable error in using Selenium with chromedriver (Python) 无法使用 chromedriver 调用模块 object - module object not callable using chromedriver TypeError: 'module' object is not callable error with driver=webdriver("C:\\\\Python34\\\\Lib\\\\site-packages\\\\selenium\\\\webdriver\\\\chromedriver.exe") - TypeError: 'module' object is not callable error with driver=webdriver("C:\\Python34\\Lib\\site-packages\\selenium\\webdriver\\chromedriver.exe") TypeError:使用Selenium WebDriver打开Chrome浏览器时无法调用“模块”对象 - TypeError: 'module' object is not callable while opening chrome browser using selenium webdriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM