[英]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:我的环境是:
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 typeerror calling the chrome
module. ...暗示调用chrome模块时出现类型
chrome
。
As per your code attempt you have used:根据您使用的代码尝试:
driver= webdriver.chrome()
Here python interprets chrome
as a submodule of webdriver
:这里python将
chrome
解释为webdriver
的子模块:
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.