使用到的软件版本:
- Flash player
- Firefox 56.0
- geckodriver 0.19.1
- python3.8.1
Python代码:
m_profile=webdriver.FirefoxProfile()
m_profile.set_preference("plugin.state.flash",2);
driver = webdriver.Firefox(firefox_profile=m_profile,executable_path="C:\\geckodriver.exe")
注意事项:
- 通过pip安装selenium
- 如果下载最新版本的Firefox浏览器和对应版本的geckodriver,每次自动化测试时打开带有flash的网页时,依然会询问是否允许flash插件启动(即便已经使用了以上代码),需要手动点击允许才能开始播放flash。
- Firefox浏览器需要关闭自动更新。