我一直试图通过Selenium访问谷歌Chrome,但无法连接到Chrome驱动程序。最初,我收到一个错误,说明我的Chrome版本不支持,但我随后下载了最新的一个关闭https://chromedriver.chromium.org/downloads,但我仍然得到一个错误。
我尝试了多种方法:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
driver=webdriver.Chrome()
输出量:
SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 117.0.5938.150 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
然后我试了这个:
driver=webdriver.Chrome(service=Service(ChromeDriverManager().install()))
输出:ConnectionError: Could not reach host. Are you offline?
下一页:driver=webdriver.Chrome(ChromeDriverManager().install())
输出:ConnectionError: Could not reach host. Are you offline?
最后:driver=webdriver.Chrome(ChromeDriverManager())
输出量:
NoSuchDriverException: Message: Unable to obtain chromedriver using Selenium Manager; 'ChromeDriverManager' object has no attribute 'capabilities'; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
如果任何人对现在可能出现的问题有任何想法,我们将不胜感激。
2条答案
按热度按时间1dkrff031#
我不是PythonMaven,但我试过了,它工作了:
u0njafvf2#
大家好,所以我想通了,我需要更新 selenium ,而不仅仅是我的chromedriver。我是通过以下方式做到这一点的:
然后我用这个代码连接:
Shoutout这个视频:https://www.youtube.com/watch?v=BnY4PZyL9cg