5

我需要一种自动化的方式来在 Firefox Selenium webdriver 中启用 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);

但这仍然需要我单击“允许”。

这一直显示,即使使用上面的代码

4

2 回答 2

5

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

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

我认为“2”也会激活插件。

于 2017-04-28T11:07:20.473 回答
1

我自己找到了解决方案。

这篇文章展示了如何在 Python 中禁用 Adob​​e Flash Player

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

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

它有效:)

于 2017-04-16T18:47:11.303 回答