5

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

Junaid Khan
  • 520
  • 6
  • 15
  • No error. Just didn't worked. As I still had to manually click the "Allow" button. – Junaid Khan Apr 12 '17 at 18:10
  • Correct me if I am wrong here but, it looks to me like all you did what pass a preference to the `driver` object. You need to tell it to _go somewhere_, also. – Brian Apr 12 '17 at 18:18
  • The site that I go into with: driver.get(link); Requires, Flash plugin to be allowed. And I have to press it manually. Just want a way to automate it too. – Junaid Khan Apr 12 '17 at 18:25
  • i've edited some of the details you mentioned in the comments into the question. if i've mis-represented the problem you're facing, please update the question again. – Woodrow Barlow Apr 13 '17 at 16:21
  • Woodrow Barlow, I don't understand, what you mean? – Junaid Khan Apr 16 '17 at 09:08

2 Answers2

5

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.

Bhurm
  • 51
  • 2
1

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 :)

Community
  • 1
  • 1
Junaid Khan
  • 520
  • 6
  • 15
  • Hi, We have still Problems with Selenium 3.5.3, geckodriver: 0.19.0 with Firefox 55.0.3(64 Bit). firefoxProfile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so","true"); firefoxProfile.setPreference("plugin.state.flash", 2); – zoram Oct 02 '17 at 08:00
  • The above post was for chrome browser and chrome driver only. – Junaid Khan Nov 16 '17 at 14:44
  • The question specifically mentions Firefox though. – Toby Sharp Apr 07 '19 at 18:13