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