Chromium 57 Plugin Management is now rearranged

When you didn’t hear, Chromium 57 has changed the way how managing the plugins works. You cannot access the plugin page in order to deactivate pdf viewer anymore. Fortunately, there is a way to still disable it, somehow. When you point into settings in chrome. You have to open the advanced settings below the page. Now go into privacy and click on the button “Content settings…”. It should pop a modal with options. Last in the list is about PDFs. You can tell the browser to open it in a different application to read PDFs. This will firstly download it and you can open it - which will solve the problem. For other stuff, you can browse chrome://flags*.

I haven’t read about the reason to deprecate the chrome://plugins* page. I hope that it will have a good reason …

The way to do it in Capybara

In order to make thing works. Go into your spec_helper.rb or rails_helper.rb to the section where you register the driver.

You will be probably having something like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Capybara.register_driver :chrome do |app|
  prefs = {
    plugins: {
      plugins_disabled: ['Chrome PDF Viewer']
    },
    download: {
      prompt_for_download: false,
      default_directory: 'desired/download/path'
    }
  }
  Capybara::Selenium::Driver.new(app, browser: :chrome, prefs: prefs)
end

You can no longer disable plugins. You can only set the option to open pdf externally. Below is the fix.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Capybara.register_driver :chrome do |app|
  prefs = {
    download: {
      prompt_for_download: false,
      default_directory: 'path/for/downloads'
    },
    plugins: {
      always_open_pdf_externally: true
    }
  }
  Capybara::Selenium::Driver.new(app, browser: :chrome, prefs: prefs)
end

Now when you start testing, scraping - whatever you want you are now downloading PDF files in your desired folders.

* Note that It won’t open for security reasons. You have to copy it and then you can go to the settings