Chrome 62 和 Flash [英] Chrome 62 and Flash
问题描述
我有一个基于 Flash 的应用程序,需要使用 Cucumber 进行测试.由于默认情况下未启用 flash,我需要在每次测试之前启用它,并将我相信的 url 列入白名单.如果我在后台暂停测试,我可以手动设置这些选项.
我怎样才能自动化这种方法,我已经考虑添加 options
和 preferences
,但似乎仍然无法开始工作.
这是我在 env.rb 文件中的标准设置
Capybara.register_driver :chrome do |app|chrome_binary = '/Applications/Google Chrome.app'能力 = 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)结尾
进一步阅读突出显示了诸如
之类的选项options = Selenium::WebDriver::Chrome::Options.newoptions.add_argument('arg-here')prefs = {"在此处启用闪存?"}options.add_experimental_option("prefs", prefs)
add_experimental_option
为 #<Selenium::WebDriver::Chrome::Options:0x007fca30c10988>
未定义的方法 add_experimental_option有人自动化了这个过程吗?
解决方案 要在每次测试前启用 Flash
和 WhiteList
url 可以使用下面的代码块来配置允许 Flash
的 WebDriver
实例:
ChromeOptions options = new ChromeOptions();映射<字符串,对象>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);
您可以在此处找到有关
这里是
I have a Flash-based app that I need to test using Cucumber. As flash is not enabled by default I need to enable it before each test and whitelist the url I believe. If I pause the test in it's background phase I can manually set these options.
How can I automate this approach though, I have looked into adding options
and preferences
, but still cannot seem to get to work.
So this is my standard setup in an env.rb file
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
Further reading has highlighted options such as
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('arg-here')
prefs = {"enable flash here ? "}
options.add_experimental_option("prefs", prefs)
The add_experimental_option
throws undefined method add_experimental_option for #<Selenium::WebDriver::Chrome::Options:0x007fca30c10988>
Has anyone automated this process?
解决方案 To enable Flash
before each test and WhiteList
the url you can use the following code block to configure the WebDriver
instance to allow Flash
:
ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
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);
Here you can find a detailed discussion on Manage Flash in Chrome
and on PluginsAllowedForUrls
Update :
You haven't mentioned in your comment through which client you are not able to find setExperimentalOption
or set_experimental_option
. Here is the snapshot from my IDE which have no errors/warnings :
And here is the JavaDoc :
这篇关于Chrome 62 和 Flash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!