2020親測可用selenium測試中flash的自動運行Firefox,Chrome

舊版Firefox才支持flash自動運行,55及以上版本不再支持flash,所以用老版本
瀏覽器版本要和webdriver匹配
這裏有匹配的版本,鏈接失效了可以私信我
鏈接:https://pan.baidu.com/s/1bP55-MByq8-6c35AQ7WKwA
提取碼:zjbl
複製這段內容後打開百度網盤手機App,操作更方便哦
記得加上下面這幾行代碼

        opts = FirefoxOptions()
        opts.add_argument("--headless")
        option_profile = webdriver.FirefoxProfile()
        option_profile.set_preference("plugin.state.flash",2)
        option_profile.set_preference("security.insecure_field_warning.contextual.enabled",False)
        #上面的部分是對瀏覽器的設置,使flash能自動播放
        self.driver = webdriver.Firefox(firefox_profile=option_profile,options=opts)

筆者隨便複製的,如果庫錯誤,沒找到,就再處理下吧
我知道這兩個至少是要的

from selenium.webdriver import FirefoxOptions
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

Chrome類似,用老版本
應用在這,看有沒有少庫
python與網課

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