2

Since geckodriver v0.16.0 flashplayer is disabled by default. Is there any possibility to start firefox with enabled flashplayer?

I'm using C#. My code right now:

var profileManager = new FirefoxProfileManager();
FirefoxProfile profile = profileManager.GetProfile("selenium"); //created firefox user named selenium
profile.SetPreference("plugin.state.flash", 1);

Code bellow doesn't work for me:

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

When I use this one:

profile.SetPreference("plugin.state.flash", 1);

firefox is asking if I want to enable flashplayer, and than refreshes page (with all inputs filled previously - so i got empty fields). If I select "allow and remember", next time I start this code nothig is saved. I'm getting the same situation.

Louis
  • 146,715
  • 28
  • 274
  • 320
Edvac
  • 31
  • 4
  • I got the same issue yesterday with the newest geckodriver. I was able to switch to chrome temporarily but would like to know a fix for this as well. – chris-crush-code Apr 26 '17 at 13:07
  • Can you share the website on which you are facing the issue with flashplayer incase its a public url? – undetected Selenium Apr 26 '17 at 13:40
  • I have this issue on every single page. For example: https://www.adobe.com/swf/software/flash/about/flashAbout_info_small.swf – Edvac Apr 26 '17 at 13:48
  • My question is which is the website you want to test/automate for which you want to enable flashplayer? – undetected Selenium Apr 26 '17 at 14:07
  • Unfortunately I can't link this website. But on every other website the issue is the same. It will change nothing, I think, even if I could. – Edvac Apr 26 '17 at 14:14
  • yeah it's literally every page with flash. It's like when geckodriver launches firefox it's launching it without the flash plugin turned off even though when manually opening it the flash plug in is turned on. – chris-crush-code Apr 26 '17 at 14:17
  • @Edvac Before I publish the solution to you I need to check my code whether it works properly or not, so reference to any other site using flashplayer will also work for me. – undetected Selenium Apr 26 '17 at 14:19
  • Ok, I can see now, that this issue is not on every site, like I was writing. I'm sorry. Now I see your point. Pages like facebook or gmail are fine, there are no issue. I'm new here and I have no idea if someone is gonna ban me, but the only site I tested which issue appears on is: myfreecams.com – Edvac Apr 26 '17 at 14:48
  • The difference between Facebook & Gmail versus your other site is that they run on secure `https://` server but your site is basic `http://`. Likely Firefox does not like to load plugin content from non-secure server. Does this [**link**](https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_embed) work fine (also https)? Just to confirm that your site/server's lack of security certificate is the issue once and for all... – VC.One Apr 27 '17 at 10:48

2 Answers2

1

I found solution there: How to enable Adobe Flash in FireFox Selenium webdriver with FirefoxProfile

If I replaced profile.setPreference("plugin.state.flash", 1); to profile.setPreference("plugin.state.flash", 2); it stopped to asking me if I want to enable flash player.

Community
  • 1
  • 1
Edvac
  • 31
  • 4
0

Here is the solution for you:

With Selenium 4.3.0, gecko driver v0.16.0 & Mozilla Firefox 53.0 this code works well with myfreecams.com.

It is worth mentioning that the default Firefox profile is not very automation friendly. When you want to run automation reliably on a Firefox browser it is advisable to make a separate profile. Automation profile should be light to load and have special proxy and other settings to run good test. You should be consistent with the profile you use on all development and test execution machines. If you used different profiles everywhere, the SSL certificates you accepted or the plug-ins you installed would be different and that would make the tests behave differently on the machines.

So, Create a New Firefox profile and use the same in the Test script involves three steps process. First you need to Start the Profile Manager, second is to Create a New Profile and third is to use the same profile in Test scripts. Let's assume we created a new FirefoxProfile by the name "debanjan".

Use the following code to open http://www.myfreecams.com/ with your new FirefoxProfile "debanjan":

    String driverPath = "C:\\Utility\\BrowserDrivers\\";
    //Mozila Firefox
    System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile testprofile = profile.getProfile("debanjan");
    DesiredCapabilities dc = DesiredCapabilities.firefox();
    dc.setCapability(FirefoxDriver.PROFILE, testprofile);
    FirefoxDriver driver =  new FirefoxDriver(dc);
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
    driver.navigate().to("http://www.myfreecams.com/");

PS: This code is in Java so you may have to convert it into C# format.

Let me know, if this helps you.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Is flashplayer turned on in your Menu->Addons->Plugins when you exetute this code? For me it's still turned off everytime I run this code – Edvac Apr 26 '17 at 15:30
  • Irrespective of the flashplayer turned on or off for the default Firefox profile, I have created a new Firefox profile by the name "debanjan" and accessed the website. It works well with the configuration mentioned in my Answer and also with recently released gecko v0.16.1 – undetected Selenium Apr 26 '17 at 15:34
  • @Edvac Are you still facing any issue? – undetected Selenium Apr 26 '17 at 16:18
  • If I use this code changed to C#, i got error: Invalid moz:firefoxOptions field acceptInsecureCerts. If I change this: DesiredCapabilities dc = DesiredCapabilities.Firefox(); dc.SetCapability(FirefoxDriver.ProfileCapabilityName, profile); FirefoxDriver driver = new FirefoxDriver(dc); To this (as compilator says): FirefoxOptions fo = new FirefoxOptions(); fo.AddAdditionalCapability(FirefoxDriver.ProfileCapabilityName, profile); FirefoxDriver driver = new FirefoxDriver(fo); It throws: There is already an option for the firefox_profile capability. Please use that instead. – Edvac Apr 26 '17 at 16:30