在 Ubuntu 14.04 上的 Headless Chrome 中运行 Flash 网页

Ric*_*wis 5 flash ubuntu google-chrome headless cucumber

我正在尝试在 Ubuntu 14.04(EC2 实例,因此没有 GUI)上使用 Chrome 无头地运行我的 Cucumber 测试。到目前为止,我的设置允许这样做,如下面的屏幕截图所示:

成功截图

当我进入带有 Flash 的页面时遇到问题:

闪存页面

我已经重新启动了 EC2 实例并杀死了所有 chrome 进程,仍然没有任何乐趣。

澄清一下,测试将开始,chrome 打开带有 Flash 的页面,我收到此消息。如果我然后结束测试并重新开始,我会遇到同样的问题。我想这实际上并不是在重新启动 chrome,因为它每次都是一个新实例?

所以为了运行这些测试,我在这里使用headlessgem作为.xvfb

我已经Google Chrome 57.0.2987.133并且已经添加libflashplayer.so/opt/google/chrome/plugins使用这个https://askubuntu.com/questions/14629/how-do-i-enable-the-partner-repository

A few extras things I have tried include:

sudo apt-get install pepperflashplugin-nonfree
sudo update-pepperflashplugin-nonfree --install
Run Code Online (Sandbox Code Playgroud)

Is there a way to get this to work so I can render flash based sites? Do I need to enable the flash plugin each time I open chrome? I'm hoping I've missed something obvious.

Update

I have tried setting the pepperflashpluginpath when creating the Chrome profile but this is still not working:

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
Run Code Online (Sandbox Code Playgroud)

Thanks

Ric*_*wis 4

要使其发挥作用,需要三个关键部分。

安装 Chromium 浏览器

sudo apt-get install chromium-browser (at time this installed version 58)
Run Code Online (Sandbox Code Playgroud)

Chrome 二进制文件现已安装在

/usr/bin/chromium-browser
Run Code Online (Sandbox Code Playgroud)

安装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
Run Code Online (Sandbox Code Playgroud)

然后运行

sudo apt-get update
sudo apt-get install adobe-flashplugin
Run Code Online (Sandbox Code Playgroud)

这将安装 flash 插件

/usr/lib/adobe-flashplugin/libflashplayer.so
Run Code Online (Sandbox Code Playgroud)

安装 Chrome 驱动程序

然后运行

sudo apt-get install chromium-chromedriver
sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriver
Run Code Online (Sandbox Code Playgroud)

差不多就是这样,这些是让我用 Cucumber 无头运行这个的步骤。