Chrome 62和Flash

我有一个基于Flash的应用程序,我需要使用Cucumber进行测试。 由于默认情况下未启用闪存,因此我需要在每次测试之前启用它,并将我认为的url列入白名单。 如果我暂停测试的后台阶段,我可以手动设置这些选项。

闪光选项

我怎么能自动化这种方法,我已经考虑过添加optionspreferences ,但似乎仍然无法开始工作。

所以这是我在env.rb文件中的标准设置

 Capybara.register_driver :chrome do |app| chrome_binary = '/Applications/Google Chrome.app' capabilities = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => { "binary" => chrome_binary + '/Contents/MacOS/Google Chrome' }) Capybara::Selenium::Driver.new(app, :browser => :chrome, :desired_capabilities => capabilities, :options => options) end 

进一步阅读强调了诸如此类的选项

 options = Selenium::WebDriver::Chrome::Options.new options.add_argument('arg-here') prefs = {"enable flash here ? "} options.add_experimental_option("prefs", prefs) 

undefined method add_experimental_option for #抛出undefined method add_experimental_option for #

有没有人自动化这个过程?

要在每次测试之前启用Flash并使用WhiteList ,您可以使用以下代码块配置WebDriver实例以允许Flash

 ChromeOptions options = new ChromeOptions(); Map prefs = new HashMap(); prefs.put("profile.default_content_setting_values.plugins", 1); prefs.put("profile.content_settings.plugin_whitelist.adobe-flash-player", 1); prefs.put("profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-player", 1); prefs.put("PluginsAllowedForUrls", "https://your_url.com"); options.setExperimentalOption("prefs", prefs); WebDriver driver = new ChromeDriver(options); 

在这里,您可以找到有关Manage Flash in ChromePluginsAllowedForUrls Manage Flash in Chrome的详细讨论

更新:

您没有在评论中提到您无法找到setExperimentalOptionset_experimental_option客户端。 以下是我的IDE中没有错误/警告的快照:

闪

这是JavaDoc

setExperimentalOption

这最终对我有用

 Capybara.register_driver :chrome do |app| chrome_binary = '/Applications/Google Chrome.app' prefs = {"profile.default_content_setting_values.plugins" => 1, "profile.content_settings.plugin_whitelist.adobe-flash-player" => 1, "profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-player" => 1, "PluginsAllowedForUrls" => "hendricks-as3.localhost.bbc.co.uk" } capabilities = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => { "binary" => chrome_binary + '/Contents/MacOS/Google Chrome', "prefs" => prefs }) Capybara::Selenium::Driver.new(app, :browser => :chrome, :desired_capabilities => capabilities) end 

阅读这些文档帮助我意识到该怎么做。 (DebanjanB的答案也帮助我了解了具体的配置文件选项,但在Java中对我的特定需求没有好处,谢谢:-))

https://sites.google.com/a/chromium.org/chromedriver/capabilities