我在selenium 4.16.0,chrome-120.0.6099.217中使用了上面的代码
from selenium.webdriver.edge.service import Service
service_obj = Service()
driver = webdriver.Chrome(service=service_obj)
driver.get("https://google.com")
我不确定您是否发布了完整的代码,无论如何,您还应该包含一个
Options()
对象并 为您的浏览器使用正确的 Options
和 Service
(导入)。
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
driver = webdriver.Chrome(options=Options(), service=Service())
driver.get("https://google.com")