Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Flash Webpage in Headless Chrome on Ubuntu 14.04

Tags:

I am trying to run my Cucumber tests headlessly with Chrome on Ubuntu 14.04 (EC2 instance so no GUI). So far my setup allows this, as the below screenshot shows:

Successful Screenshot

I have an issue when I come to a page with flash on it:

Flash page

I have restarted the EC2 instance and killed all chrome processes, still no joy.

To clarify, a test will start and chrome opens the page with flash on it and I get this message. If I then end the test and start it again I get the same problem. I guess this is not actually restarting chrome as it is a new instance each time?

So to run these tests I am using the headless gem here which acts as the interface to xvfb.

I have Google Chrome 57.0.2987.133 and have added libflashplayer.so to /opt/google/chrome/pluginsusing this 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

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

Thanks

like image 1000
Richlewis Avatar asked Apr 15 '17 20:04

Richlewis


People also ask

How do I run Chrome in headless mode?

Which command starts the google chrome web browser in headless mode? As we have already seen, you just have to add the flag –headless when you launch the browser to be in headless mode. With CLI (Command Line Interface), just write: chrome \<br> – headless \ # Runs Chrome in headless mode.

How do I run Chrome headless in Linux?

You can run Google Chrome in headless mode simply by setting the headless property of the chromeOptions object to True. Or, you can use the add_argument() method of the chromeOptions object to add the –headless command-line argument to run Google Chrome in headless mode using the Selenium Chrome web driver.

Does Chromium support headless?

Headless Chromium allows running Chromium in a headless/server environment. Expected use cases include loading web pages, extracting metadata (e.g., the DOM) and generating bitmaps from page contents -- using all the modern web platform features provided by Chromium and Blink.


1 Answers

There were three key parts in getting this to work.

Install Chromium Browser

sudo apt-get install chromium-browser (at time this installed version 58)

The Chrome binary is now installed at

/usr/bin/chromium-browser

Install Flash plugin

https://askubuntu.com/questions/531672/how-to-install-flash-payer-in-ubuntu-14-04-lts

First go to /etc/apt/sources.list and uncomment the lines

deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner

Then run

sudo apt-get update
sudo apt-get install adobe-flashplugin

This installs the flash plugin at

/usr/lib/adobe-flashplugin/libflashplayer.so

Install Chrome Driver

Then run

sudo apt-get install chromium-chromedriver
sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriver

That's pretty much it, these were the steps that got me running this with Cucumber headless.

like image 131
Richlewis Avatar answered Sep 24 '22 11:09

Richlewis