driver=webdriver.chrome() TypeError: 'module' object is not callable
时间: 2023-10-17 16:25:46 浏览: 252
webdriver.Chrome
报错信息"driver=webdriver.chrome() TypeError: 'module' object is not callable"表示webdriver模块中的chrome方法不能被调用。这个问题可能是因为在代码中使用了错误的方法名。正确的方法应该是`webdriver.Chrome()`而不是`webdriver.chrome()`。请确保方法名大写开头并且括号中没有任何参数。修改代码如下:
```python
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
time.sleep(3)
driver.find_element_by_id("kw").send_keys("花千骨")
driver.find_element_by_id("su").click()
driver.quit()
```
这样修改后,你的代码应该可以正常运行了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Python selenium中出现错误:driver = webdriver.chrome() TypeError: ‘module‘ object is not callable](https://blog.csdn.net/qq_55660421/article/details/127528327)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [解决webdriver.Chrome()报错:Message:'chromedriver' executable needs to be in Path](https://download.csdn.net/download/weixin_38697328/12862713)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文