我有一个基于Flash的应用程序,我需要使用Cucumber进行测试。由于默认情况下未启用闪存,因此我需要在每次测试之前启用它,并将我认为的网址列入白名单。如果我暂停测试的背景阶段,我可以手动设置这些选项。
我怎样才能自动化这种方法,我已经考虑过添加options
和preferences
,但似乎仍无法开始工作。
所以这是我在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)
add_experimental_option
抛出undefined method add_experimental_option for #<Selenium::WebDriver::Chrome::Options:0x007fca30c10988>
有没有人自动完成此过程?
答案 0 :(得分:0)
这最终对我有用
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