Python Selenium如何解决'module' object is not callable报错
报错原因
你调用的webdriver.chrome是Selenium里的子模块,不是可实例化的类,所以会触发模块不可调用的报错。Selenium中Chrome浏览器的驱动类是大写开头的Chrome,属于webdriver模块下的可调用对象。
修复方法
直接修改实例化driver的一行代码,把小写的chrome改为大写的Chrome即可。
修改后的完整可运行代码:
from selenium import webdriver from selenium.webdriver.chrome.options import Options option = Options() option.add_argument("start-maximized") # 此处chrome改为首字母大写的Chrome driver = webdriver.Chrome(options=option) driver.get("http://twitter.com/login")
如果你使用的是Selenium 4.6及以上版本,不需要额外手动下载配置ChromeDriver,Selenium内置的驱动管理工具会自动匹配你本地Chrome版本对应的驱动。
内容的提问来源于stack exchange,提问作者sparsh
相关产品推荐
相关产品推荐

