Chrome 54.0.2840.59-1的最新更新导致selenium无法加载Flash插件。Adobe Flash Player在chrome://plugins/
被禁用,但它也在以前版本的Chrome禁用。
这只发生在Chromedriver启动的测试中,在正常的Chrome浏览器中导航到Flash站点没有问题。
从https://get.adobe.com/flashplayer/安装flash播放器在mac OS上为我工作,请注意,您需要将其安装在chrome驱动程序浏览器上(而不是您系统中的chrome浏览器)。要做到这一点,运行selenium测试,打开chrome,从那里转到那个URL ^并按照安装步骤。在您完成这些之后,下次运行测试时,它应该能够拾取更改并工作。
@sircapsalot:这是可能的,我们的应用程序是在flash中构建的自动化。它要求我们添加自定义的flex处理程序,然后可以通过javascript调用。
Linux:为了让flash在chrome 54上工作,我从我的/usr/google-chrome中获取了插件文件的工作副本,然后我能够在命令行参数中使用pass到chromedriver:
ClassLoader classLoader = getClass().getClassLoader(); File flashPath = new File(classLoader.getResource("libpepflashplayer.so").getFile());
ChromeOptions options = new ChromeOptions(); options.addArguments("--ppapi-flash-path=" + flashPath);
return new ChromeDriver(serviceBuilder.build(), options);
Windows: @user7038292的解决方案安装flash手动解决问题
Chrome 54不再支持Adobe Flash Player NPAPI。所以你应该安装Adobe Flash Player PPAPI(从https://get.adobe.com/flashplayer/)在chrome浏览器在您的系统。
HashMap<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("plugins.plugins_enabled", new String[] {
"Chrome PDF Viewer",
"Native Client"
});
chromePrefs.put("plugins.plugins_disabled", new String[] {
"Adobe Flash Player"
});
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
从Chrome 53开始,他们已经阻止flash在浏览器上加载。您使用的是54,所以它适用。
其次,硒不能自动Flash,所以我认为这个问题是毫无意义的。如果你需要自动化flash,你应该考虑另一个库。
安装Flash为我修复了这个问题,我以前使用过chrome的pepperflash,遇到了你所描述的同样的问题。