Chrome 62和闪光灯 [英] Chrome 62 and flash
问题描述
我有一个基于Flash的应用程序,我需要使用黄瓜测试。由于默认情况下未启用Flash,因此我需要在每次测试之前启用它,并将我相信的网址列入白名单。如果我暂停在后台阶段的测试,我可以手动设置这些选项
我怎样才能自动化这种方法,我已经看过添加选项
和首选项
,但仍然
所以这是我在env.rb文件中的标准设置
Capybara.register_driver:chrome do | app |
throws
chrome_binary ='/ Applications / Google Chrome.app'
capabilities = Selenium :: WebDriver :: Remote :: Capabilities.chrome(chromeOptions=> {binary=> chrome_binary + /内容/ MacOS /谷歌浏览器'))
Capybara :: Selenium :: Driver.new(app,:browser =>:chrome,:desired_capabilities => capabilities,:options => options)
end
$ / code $
进一步阅读已经突出显示了诸如
options = Selenium :: WebDriver :: Chrome :: Options.new
options.add_argument('arg-here')
prefs = {enable闪光在这里?)
options.add_experimental_option(prefs,prefs)
code> add_experimental_option
未定义的方法add_experimental_option for#< Selenium :: WebDriver :: Chrome :: Options:0x007fca30c10988>
有没有人自动执行这个过程?
任何帮助表示感谢,
在每次测试之前启用Flash
和WhiteList
可以使用下面的url代码块来配置WebDriver
实例以允许Flash
:ChromeOptions options = new ChromeOptions();
地图< 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驱动程序=新的ChromeDriver(选项);
您可以在这里找到
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
andpreferences
, 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
throwsundefined method add_experimental_option for #<Selenium::WebDriver::Chrome::Options:0x007fca30c10988>
Has anyone automated this process?
Any help appreciated, thank you
解决方案To enable
Flash
before each test andWhiteList
the url you can use the following code block to configure theWebDriver
instance to allowFlash
: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 onPluginsAllowedForUrls
Update :
You haven't mentioned in your comment through which client you are not able to find
setExperimentalOption
orset_experimental_option
. Here is the snapshot from my IDE which have no errors/warnings :And here is the JavaDoc :
这篇关于Chrome 62和闪光灯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文