Giter Club home page Giter Club logo

headless-chrome-fail-case's Introduction

headless-chrome-fail-case

An MWE to show the limitations of headless chrome when downloading a PDF from a new tab link. The options and preferences used to configure chrome were taken from this chromium thread. These comments are old, but it's the only one to seem to have gotten things working with capybara.

Installation

Install the required gems and drivers.

Running the example

Start an http server in this directory

I'm a python person, so I use:

  • python3 -m http.server

Visit http://localhost:8000 and try out both links. Both should point to our sample PDF, one in a new tab and one not.

Test download with headless chrome

Run the ruby code that uses headless chrome / selenium to download this:

  • ruby download_pdf.rb

By default this will attempt to download the new tab PDF. It won't fail, but there won't be any files listed in the DOWNLOAD_PATH at the end of the script.

Test normal (no new tab) download

Edit download_pdf.rb to find id: "normal_link" on line 9, then run ruby download_pdf.rb again. This time the DOWNLOAD_PATH should have a PDF file in it, which you can go in and open.

Test new tab download with headed chrome

Restore download_pdf.rb to its original state, so it's looking for id: "newtab_link". Then open scrapppy.rb and comment out line 18, where we're specifying that chrome run in --headless mode. Save and then run ruby download_pdf.rb again. Chrome will start in headed mode, then successfully download the new tab PDF.

System info and versions

  • capybara (2.18.0)
  • selenium-webdriver (3.141.0)
  • ChromeDriver 2.44.609545

headless-chrome-fail-case's People

Contributors

dissolved avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.