Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Adobe Flash in FireFox Selenium webdriver with FirefoxProfile

I need an automated way to enable Flash in the Firefox Selenium webdriver without user interaction.

I have tried:

FirefoxProfile profile = new FirefoxProfile();
//As 0 is to disable, I used 1. I don"t know what to use.
profile.setPreference("plugin.state.flash", 1);
WebDriver driver = new FirefoxDriver(profile);

But this still requires me to click "Allow".

This is shown all the time, even with the code above

like image 711
Junaid Khan Avatar asked Apr 12 '17 18:04

Junaid Khan


2 Answers

This didn't work for me: profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so","true");

Instead I used: profile.setPreference("plugin.state.flash", 2);

I presume the "2" also activates the plugin.

like image 189
Bhurm Avatar answered Oct 03 '22 05:10

Bhurm


I found the solution myself.

This Post Shows how to disable Adobe flash Player in Python

And to enable it in "JAVA", Just change the false to true.

profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so","true");

And it works :)

like image 34
Junaid Khan Avatar answered Oct 03 '22 05:10

Junaid Khan