如何使用 FirefoxProfile 在 FireFox Selenium webdriver 中启用 Adob​​e Flash

How to enable Adobe Flash in FireFox Selenium webdriver with FirefoxProfile

我需要一种无需用户交互即可在 Firefox Selenium 网络驱动程序中启用 Flash 的自动化方法。

我试过:

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

但这仍然需要我点击"Allow"。

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

我自己找到了解决方案。

This Post Shows how to disable Adobe flash Player in Python

要在 "JAVA" 中启用它,只需将 false 更改为 true。

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

而且有效:)

这对我不起作用: profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so","true");

相反,我使用了: profile.setPreference("plugin.state.flash", 2);

我想“2”也会激活插件。