抱歉,我的Selenium是4.10.0版本
时间: 2024-04-14 09:30:40 浏览: 20
非常抱歉,我之前的回答假设你使用的是 Selenium 3.0 版本。由于你的 Selenium 版本是 4.10.0,那么问题可能不是版本兼容性导致的。
根据你提供的错误信息,`webdriver.Chrome()` 方法不再支持 `executable_path` 参数。在 Selenium 4 中,你需要使用 `executable_path` 参数的替代方法。以下是一个更新的代码示例:
```python
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
chrome_driver_path = "path/to/chromedriver"
options = webdriver.ChromeOptions()
# 设置其他选项
# options.add_argument("--headless")
service = Service(chrome_driver_path)
driver = webdriver.Chrome(service=service, options=options)
```
在上面的代码中,我们首先导入了 `webdriver` 和 `Service` 类。然后,我们创建了一个 `Service` 对象,并将其传递给 `webdriver.Chrome()` 中的 `service` 参数。最后,我们将 `options` 对象传递给 `webdriver.Chrome()` 中的 `options` 参数。
请确保将 `chrome_driver_path` 替换为你实际的 ChromeDriver 的路径。
希望这能帮助你解决问题!如果问题仍然存在,请提供更多的代码和错误信息,以便我更好地帮助你。
相关推荐
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![whl](https://img-home.csdnimg.cn/images/20210720083646.png)
![tar](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)