如何启用Flash到HTMLUnit? [英] How to enable Flash to HTMLUnit?
问题描述
< code>< code>< code>< object>
pre $ web $ c $ webClient.getOptions()。setJavaScriptEnabled(true);
webClient.getOptions()。setActiveXNative(true);
webClient.getOptions()。setAppletEnabled(true);
webClient.getOptions()。setCssEnabled(true);
在一些地方,我发现 someone 表示HTMLUnit将不支持Flash,但这些答案似乎是旧的,所以提出这个问题。有人请帮忙。
Thanks。
我发现它与 help
为此,我将2.15的HTMLUnit版本降级到2.13,如2.15 BrowserVersionFeatures.JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW
似乎不推荐使用,不知道在这里替换了什么功能。
private static BrowserVersion firefox17WithUptoDateFlash = new BrowserVersion(BrowserVersion。 FIREFOX_17.getApplicationName(),BrowserVersion.FIREFOX_17.getApplicationVersion(),BrowserVersion.FIREFOX_17.getUserAgent(),BrowserVersion.FIREFOX_17.getBrowserVersionNumeric(),新BrowserVersionFeatures [] {
BrowserVersionFeatures.JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW,
BrowserVersionFeatures.STYLESHEET_HREF_EXPANDURL ,
BrowserVersionFeatures.STYLESHEET_HREF_STYLE_NULL
});
static {
PluginConfiguration plugin1 = new PluginConfiguration(
Shockwave Flash,
Shockwave Flash 11.4 r402,
NPSWF32_11_4_402_287.dll);
plugin1.getMimeTypes()。add(new PluginConfiguration.MimeType(
application / x-shockwave-flash,
Adobe Flash movie,
swf)) ;
firefox17WithUptoDateFlash.getPlugins()。add(plugin1);
}
最终的WebClient webClient =新的WebClient(firefox17WithUptoDateFlash);
这里新编写的浏览器实例将支持htmlunit作为flash启用的无GUI浏览器p>
I'm trying to grab html contents by HTMLUnit. Everything went nice, but couldn't get Flash contents those are visible as <img>
where its actually in <object>
, i have
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setActiveXNative(true);
webClient.getOptions().setAppletEnabled(true);
webClient.getOptions().setCssEnabled(true);
In SO some places i found someone saying HTMLUnit won't support Flash, but those answers seems old, so am raising this question. Someone please help. Thanks.
I found it with the help
for this i have downgrade my HTMLUnit version from 2.15 to 2.13 as in 2.15 BrowserVersionFeatures.JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW
seems deprecated and don't know what feature replaced here.
private static BrowserVersion firefox17WithUptoDateFlash = new BrowserVersion(BrowserVersion.FIREFOX_17.getApplicationName(), BrowserVersion.FIREFOX_17.getApplicationVersion(), BrowserVersion.FIREFOX_17.getUserAgent(), BrowserVersion.FIREFOX_17.getBrowserVersionNumeric(),new BrowserVersionFeatures[]{
BrowserVersionFeatures.JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW,
BrowserVersionFeatures.STYLESHEET_HREF_EXPANDURL,
BrowserVersionFeatures.STYLESHEET_HREF_STYLE_NULL
});
static {
PluginConfiguration plugin1 = new PluginConfiguration(
"Shockwave Flash",
"Shockwave Flash 11.4 r402",
"NPSWF32_11_4_402_287.dll");
plugin1.getMimeTypes().add(new PluginConfiguration.MimeType(
"application/x-shockwave-flash",
"Adobe Flash movie",
"swf"));
firefox17WithUptoDateFlash.getPlugins().add(plugin1);
}
final WebClient webClient = new WebClient(firefox17WithUptoDateFlash);
Here newly written browser instance will give support to htmlunit to act as flash enabled GUI-less browser
这篇关于如何启用Flash到HTMLUnit?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!