安裝chromedriver

下載地址:https://googlechromelabs.github.io/chrome-for-testing/

打開chrome,點(diǎn)幫助 --> 關(guān)于Google Chrome



在上述下載地址中找到以下對應(yīng)版本內(nèi)容



下載對應(yīng)系統(tǒng)的chromedriver


$ vi selenium_test.py

編寫以下python測試代碼

# -*- coding: utf-8 -*-

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options

url = 'https://www.google.com'
options = Options()
options.headless = True
service = Service(executable_path='/path/to/your/chromedriver-mac-x64/chromedriver')  # 替換為你的ChromeDriver路徑
driver = webdriver.Chrome(service=service, options=options)
driver.get(url)

time.sleep(5)  # 等待頁面加載完畢
driver.quit()

web驅(qū)動模擬打開指定網(wǎng)頁


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容