当使用python编写自动化框架时

如果在调用chromdriver启动chrome时,报错信息为:Exception managing chrome: error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json),

代码信息为

from selenium import webdriver

driver = webdriver.Chrome()
print("11")
driver.get("https://www.baidu.com/")
print("22")

解决办法如下:

补充chromedriver的路径,即可解决这个问题。

from selenium import webdriver
from selenium.webdriver.chrome.service import Service


driver_path = "chromedriver.exe"
service = Service(executable_path=driver_path)
driver = webdriver.Chrome(service=service)
print("11")
driver.get("https://www.baidu.com/")

注意:service中用到的参数必须为executable_path否则问题无法解决。

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐