Selenium怎样指定chromedriver的路径

怎样指定chromedriver的路径

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

# 启动Chrome浏览器,指定driver路径
path = Service(r"C:\webdriver\chromedriver.exe")
driver = webdriver.Chrome(service=path)

driver.get("http://antpython.net/")

print(driver.title)

driver.close()

执行效果:
file

Leave a Comment