Activate Flash Player with Junit

Asked

Viewed 45 times

0

good afternoon.

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

Follows 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 many sites talking about using Hashmap, but when I try to use it, you don’t recognize it at all.

Can you help me please?

Thanks in advance.

1 answer

0


Following solution to the problem in Chrome version 70:

Here’s 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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.