我正在尝试在 Ubuntu 14.04(EC2 实例,因此没有 GUI)上使用 Chrome headless (headless)地运行我的 Cucumber 测试。到目前为止,我的设置允许这样做,如下面的屏幕截图所示:
当我来到一个带有 flash 的页面时,我遇到了一个问题:
我已经重新启动了 EC2 实例并终止了所有 chrome 进程,仍然没有任何乐趣。
澄清一下,测试将开始,chrome 打开带有 flash 的页面,我收到此消息。如果我然后结束测试并重新开始,我会遇到同样的问题。我想这实际上并没有重新启动 chrome,因为它每次都是一个新实例?
因此,为了运行这些测试,我使用了 headless
gem here,它作为 xvfb
的接口(interface)。
我有 Google Chrome 57.0.2987.133
并已将 libflashplayer.so
添加到 /opt/google/chrome/plugins
使用此 https://askubuntu.com/questions/14629/how-do-i-enable-the-partner-repository
我尝试过的一些额外的事情包括:
sudo apt-get install pepperflashplugin-nonfree
sudo update-pepperflashplugin-nonfree --install
有没有办法让它工作,以便我可以呈现基于 Flash 的网站?每次打开 chrome 都需要启用 flash 插件吗?我希望我错过了一些明显的东西。
更新
我已经尝试在创建 Chrome 配置文件时设置 pepperflashpluginpath
但这仍然不起作用:
Capybara.register_driver :chrome do |app|
chrome_binary = '/usr/bin/google-chrome'
Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => { "binary" => chrome_binary, "args" => ["--ppapi-flash-path=/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so"] })
Capybara::Selenium::Driver.new(app, :browser => :chrome, :desired_capabilities => capabilities)
end
谢谢
最佳答案
要让它发挥作用,需要三个关键部分。
安装 Chromium 浏览器
sudo apt-get install chromium-browser (at time this installed version 58)
Chrome 二进制文件现在安装在
/usr/bin/chromium-browser
安装Flash插件
https://askubuntu.com/questions/531672/how-to-install-flash-payer-in-ubuntu-14-04-lts
首先转到 /etc/apt/sources.list
并取消注释行
deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner
然后运行
sudo apt-get update
sudo apt-get install adobe-flashplugin
这会在
安装 flash 插件/usr/lib/adobe-flashplugin/libflashplayer.so
安装 Chrome 驱动程序
然后运行
sudo apt-get install chromium-chromedriver
sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriver
差不多就是这些,这些是让我用 Cucumber headless 运行它的步骤。
关于google-chrome - 在 Ubuntu 14.04 上的 Headless Chrome 中运行 Flash 网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43431076/