我們在用Selenium做自動化測試時,有時候需要瀏覽器自動加載flash插件,69以前的谷歌瀏覽器,可以通過加載屬性的方法自動運行flash插件,如下:
prefs={ "profile.managed_default_content_settings.images":1, "profile.content_settings.plugin_whitelist.adobe-flash-player":1, "profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-player":1, } chromeOpitons .add_experimental_option('prefs',prefs)
但是69以后的高版本,為了安全性,谷歌禁止了自動加載flash插件,那么怎么辦呢?下面介紹一種修改注冊表的方法,讓瀏覽器自動加載flash插件
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\SOFTWARE\Policies\Chromium] "AllowOutdatedPlugins"=dword:00000001 "RunAllFlashInAllowMode"=dword:00000001 "DefaultPluginsSetting"=dword:00000001 "HardwareAccelerationModeEnabled"=dword:00000001 [HKEY_CURRENT_USER\SOFTWARE\Policies\Chromium\PluginsAllowedForUrls] "1"="https://*" "2"="http://*" [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome] "AllowOutdatedPlugins"=dword:00000001 "RunAllFlashInAllowMode"=dword:00000001 "DefaultPluginsSetting"=dword:00000001 "HardwareAccelerationModeEnabled"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\PluginsAllowedForUrls] "1"="https://*" "2"="http://*"
把上面代碼拷貝到txt文本中,重命名以.reg結尾的文件,如:chrome自動運行flash.reg,然后雙擊運行這個文件就行了。