macOS使用Selenium操作Firefox瀏覽器


瀏覽器及驅動版本對應關系如下:

將下載后的gecokdriver解壓后移動或軟鏈到/usr/local/bin

mv ~/Downloads/gecokdrier /usr/local/bin

編寫腳本:

from selenium import webdriver
from time import sleep


dr = webdriver.Firefox()

dr.get('https://www.baidu.com/')

dr.find_element('id', 'kw').send_keys('博客園 韓志超')
dr.find_element('id', 'su').click()
sleep(3)

dr.quit()

運行結果如下圖:

參考鏈接:https://www.selenium.dev/downloads/
https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM