I'm trying to use chrome headless to print my webpage to a PDF file. The PDf file is with no data, because the headless chrome is printing it before the ajax commands finish.
Any idea on how I can get it to wait?
Here's the command I currently use:
chrome --headless http://localhost:8080/banana/key --run-all-compositor-stages-before-draw --print-to-pdf=C:\\tmp\\tmp.pdf
Headless mode is a functionality that allows the execution of a full version of the latest Chrome browser while controlling it programmatically. It can be used on servers without dedicated graphics or display, meaning that it runs without its “head”, the Graphical User Interface (GUI).
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.
As an alternative, and for more functionality, you can run headless Chrome using Puppeteer. Puppeteer is a Node. js library and, as a result, you are writing commands for the headless browser in JavaScript code which is considerably easier than writing those commands in a command line.
211. This version is released for Windows, Linux, Mac, iOS and android versions and has number of fixes and improvements. Chrome 59 Mac edition supports Headless Mode which is used for modern web automation testing as this mode works without graphical user interface.
chrome --headless http://localhost:8080/banana/key --run-all-compositor-stages-before-draw --print-to-pdf=C:\\tmp\\tmp.pdf --virtual-time-budget=10000
Try this, virtual-time-budget
is the parameter which can delay it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With