4

I've been using this to allow flash for chrome version 69.

ChromeOptions options = new ChromeOptions();
// disable ephemeral flash permissions flag
options.addArguments("--disable-features=EnableEphemeralFlashPermission");
Map<String, Object> prefs = new HashMap<>();
// Enable flash for all sites for Chrome 69
prefs.put("profile.content_settings.exceptions.plugins.*,*.setting", 1);

options.setExperimentalOption("prefs", prefs);
nestedDriver = new ChromeDriver(options);

Now on version 71 of chrome, this experimental feature (EphemeralFlashPermission) has been removed.

I've also tried to use these settings but it didn't work as well.

prefs.put("profile.default_content_setting_values.plugins", 1);
prefs.put("profile.content_settings.plugin_whitelist.adobe-flash-player", 1);
prefs.put("profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-player", 1);

Is there any other way now to enable flash using chromedriver?

Morta1
  • 609
  • 7
  • 20

2 Answers2

10

I haven't find any option yet, and I'm afraid won't find ever.

The workaround for Windows is to use Group Policies (via adding entries to registry):

reg add HKLM\Software\Policies\Google\Chrome /v DefaultPluginsSetting /d 1 /t REG_DWORD /f
reg add HKLM\Software\Policies\Google\Chrome\PluginsAllowedForUrls /v 1 /d http://* /t REG_SZ /f
reg add HKLM\Software\Policies\Google\Chrome\PluginsAllowedForUrls /v 2 /d https://* /t REG_SZ /f

or just create file with .reg extension and put text below into it:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google]

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]
"DefaultPluginsSetting"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\PluginsAllowedForUrls]
"1"="http://*"
"2"="https://*"

then save and double-click this file.

doctordrue
  • 244
  • 1
  • 3
  • 6
0

My little workaround about this, ty to @doctordrue ;)

from winreg import *
import sys

reg_path = 'Software\Policies\Google\Chrome\PluginsAllowedForUrls'

allow_flash = {'1': 'https://url'}

if sys.platform == 'win32':
    try:
        try:
            RegistryKey = OpenKey(HKEY_LOCAL_MACHINE, reg_path, 0, KEY_ALL_ACCESS)
            for K,V in allow_flash.items():
                try:
                    if QueryValueEx(RegistryKey, K)[0] == V: pass
                    else:
                        SetValueEx(RegistryKey, K, 0, REG_SZ, V)
                except FileNotFoundError:
                    SetValueEx(RegistryKey, K, 0, REG_SZ, V)
            CloseKey(RegistryKey)
        except FileNotFoundError:
            RegistryKey = CreateKey(HKEY_LOCAL_MACHINE, reg_path)
            for K, V in allow_flash.items():
                SetValueEx(RegistryKey, K, 0, REG_SZ, V)
            CloseKey(RegistryKey)
    except:
        # write_in_log(traceback.format_exc())
        pass
Acamori
  • 327
  • 1
  • 5
  • 15