macos selenium firefox chrome safari driver

要不edge就算了吧。。

macos 10.15.4

python 3.6.8

pip3 install selenium    #安裝selenium

1、firefox 76.0.1

    1.1、使用brew安裝geckodriver

brew install geckodriver

    1.2、測試

from selenium import webdriver
from time import sleep

f = webdriver.Firefox()
f.get('https://www.baidu.com')
sleep(5)
f.close()

2、chrome 83.0.4103.61

    2.1、根據chrome版本登錄【http://npm.taobao.org/mirrors/chromedriver/】下載對應文件

    2.2、【系統偏好設置】->【安全與隱私】->允許chromedriver運行

    2.3、移動到/usr/local/bin目錄

mv chromedriver /usr/local/bin

    2.4、測試

from selenium import webdriver
from time import sleep

c = webdriver.Chrome()
c.get('https://www.baidu.com')
sleep(5)
c.close()

3、safari 13.1

    3.1、【開發】->【允許遠程自動化】

    3.2、測試

from selenium import webdriver
from time import sleep

s = webdriver.Safari()
s.get('https://www.baidu.com')
sleep(5)
s.close()

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章