Enable Flash Player with JUnit

0

Good afternoon.

I'm trying to enable Adobe Flash Player in Chrome's Headless, but I'm not getting it.

Follow my code:

public class testes {

    @Test
    public void inicializa() {

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--start-maximized");
        options.addArguments("--ignore-certificate-errors");
        options.addArguments("--disable-popup-blocking");
        options.addArguments("--incognito");

        options.setExperimentalOption("excludeSwitches", Arrays.asList("disable-component-update"));
        options.addArguments(Arrays.asList("--always-authorize-plugins","--allow-outdated-plugins"));    
        WebDriver driver = new ChromeDriver(options);

        driver.manage().window().maximize();
        driver.get(url);
    }
}

I've seen a lot of websites talking about using HashMap, but when I try to use it, I do not recognize it in any way.

Can you help me out?

Thank you in advance.

    
asked by anonymous 03.12.2018 / 17:59

1 answer

0

Here is the solution to the problem in Chrome version 70:

Here is the solution I found to the problem:

@Test public void initializes () {

ChromeOptions options = new ChromeOptions();
WebDriver driver;

// Esta linha desabilita uma função no Chrome que define se poderá habilitar automaticamente o Adobe Flash ou não.
options.addArguments("--disable-infobars", "--disable-features=EnableEphemeralFlashPermission");
Map<String, Object> prefs = new HashMap<>();

// Este trecho faz com que todos os sites possuam permissão para habilitar o Adobe Flash automaticamente
// Essa linha depende da linha acima.
prefs.put("profile.content_settings.exceptions.plugins.*,*.setting", 1);
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);
prefs.put("PluginsAllowedForUrls", "Informe sua URL aqui");

//Inicia o browser maximizado
options.addArguments("--start-maximized");

options.setExperimentalOption("prefs", prefs);

driver = new ChromeDriver(options);

driver.get(url);

driver.findElement(By.id("elemento")).click();

}

Thank you for your attention.

    
04.12.2018 / 13:58