generate pdf use headlesschrome

I want to generate pdf automatically, so i use headlesschrome feature.
This is my code to generate pdf:

$headlessChromer = new HeadlessChrome();

                        $headlessChromer->setBinaryPath('C:Program Files (x86)GoogleChromeApplicationchrome');

But i want to generate base on id, where i have to place the where condition ?

Is it possible to make the devtool status off when using Puppeteer?

is it possible to make the devtool status off when using Puppeteer?
because there are some websites that protect their pages from being inspected using devtool, so it can not be accessed using Puppeteer.

I opened this url,output to check devtool status

const browser = await puppeteer.launch({
  headless: false,
  devtools: false,
const page = await browser.newPage();
await page.goto(',output');

is there any way to make this status off?

Service worker installation in Headless Chrome (via puppeteer)

I have a service worker that is registered with

if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register('/service-worker.bundle.js').then(registration => {
        console.log('Service worker was registered');
    }).catch(error => {
        console.log('Registration failed: ', error);

The actual service worker is logging its install and activate events with regular console.log() calls, all of this is working as expected.

However, when it came to the testing automation, the Headless Chrome / puppeteer solution is not working as it was expected, the service worker is not installed (the install event does not happen). So, the question is, is there any special way of testing pages with service workers with Headless Chrome / puppeteer?

The puppeteer code:

const puppeteer = require(‘puppeteer’);

(async () => {
  const browser = await puppeteer.launch({ args: ['--no-sandbox']});
  const page = await browser.newPage();
  page.on('console', msg => console.log('PAGE LOG:', msg.text()));

  await page.goto('https://***.com', { waitUntil: 'networkidle0' });
  await page.waitFor(1*4000);
  console.log('Before reload');
  await page.reload({ waitUntil: 'networkidle0' });
  await page.screenshot({path: 'public/vidi.png'});
  await browser.close();


Headless Chrome


Chrome DevTools Protocol

Merge contents from multiple URLs in single PDF with headless Chrome

I use the print-to-pdf feature of headless Chrome to create a PDF of a given web page. What I would need, though, is to get two separate web pages into one single PDF file. Is that possible using headless Chrome?

How to use frames in cdp4j

Trying to work with frames/iframes in cdp4j. It doesn’t seem clear how to obtain a “frame context id” or to work with frames at all, like find elements in a frame, focus a field within a frame, click an element in a frame, etc.

Getting flattened DOM in ChromeDevTools

I’d like to programmatically get the HTML for all frames (including iFrames) of the final DOM as it appears in the Elements tab.

At the moment, I’m using the following to grab the DOM (as HTML), however, this does not pierce the iFrames (as the context is of the top frame):"document.documentElement.outerHTML;")['result']['value']

I’m using the following library to issue the requests.

Thinking I’ll need to iterate over all the frames and dump it like the above?

Using Devtools protocol event Page.frameNavigated to get client side navigation redirects

The framenavigated event in the Devtools protocol doesn’t seem to be working the same way as the framenavigated event in Puppeteer. If I use the parentframe method in the Puppeteer example below I only get the client side navigation redirects which is what I want. If I use the Devtools protocol example replacing the parentframe method with parentId I don’t get anything because the code doesn’t get past parentId.

How can I use the framenavigated event in the Devtools protocol to behave the same way as Puppeteer framenavigated and only get the navigation redirect chain?

// var url = "";
var url = "";

const puppeteer = require('puppeteer');

puppeteer.launch().then(async browser => {
const page = await browser.newPage();

// Puppeteer framenavigated example:
page.on('framenavigated', frame => {
 if(frame.parentFrame() === null) {
console.log("Puppeteer nav frame: ");
// Result returns:
// Puppeteer nav frame:

// Devtools protocol framenavigated example:
const client = await;
await client.send('Page.enable');

await client.on('Page.frameNavigated', (e) => {
// console.log("Framenavigated event fired");
if(e.frame.parentId === null) {
    console.log("Devtools protocol frame: ");
// Result returns: 
// Either hangs up and times out or finishes but returns nothing

await page.goto(url);
await browser.close();


Using Network.requestIntercepted with Puppeteer

I’m trying to get urls of navigation/domain redirects using the Chrome Dev tools Network.requestIntercepted event through Puppeteer, but I cant seem to access any of the events data.

The code below doesn’t seem to trigger Network.requestIntercepted and I can’t work out why.

Any help appreciated.

// console command
// node chrome-commands.js test

var url = process.argv[2];
const puppeteer = require('puppeteer');

puppeteer.launch().then(async browser => {
const page = await browser.newPage();
const client = await;
await client.send('Network.enable');

await client.on('Network.requestIntercepted', (e) => {
  console.log("EVENT INFO: ");

  await page.goto(url);
  await browser.close();

Puppeteer: Network.setCookie returns invalid string param

I’m learning to use the CDPSession class in Puppeteer, but I’m having trouble with using the method parameters of the dev tools protocol.

Dev Tools Network

The Network.setCookie section of the Dev tools docs show the params for setting the name cookie are: name string, but when I do this it returns an error: Error: Protocol error (Network.setCookie): Invalid parameters value: string value expected.

What am I doing wrong?

const puppeteer = require('puppeteer');

puppeteer.launch().then(async browser => {
  const page = await browser.newPage();
const client = await;
await client.send('Network.enable');
const setCookie = await client.send('Network.setCookie', {
  name: 'mycookie'
  // secure: true
console.log("Set Cookie: " + setCookie.success);
await page.goto('');
  await browser.close();

how to prevent Chrome headless from loading images

I am running a test in headless chrome and part of it I want to prevent the browser from loading the images on the page, the page must be a data url and not a normal page.
I am using headless chrome with the next start command:
chrome --headless --remote-debugging-port=9222

I had created the next test to demonstrate what I am trying to achieve.
but nothing works…

const CDP = require('chrome-remote-interface');
const fs = require('fs');

CDP(async(client) => {
  const {
  } = client;
  try {
    await Page.enable();
    await Network.enable();
    await Network.emulateNetworkConditions({
      offline: true,
      latency: 0,
      downloadThroughput: 0,
      uploadThroughput: 0
    await Page.navigate({
      url: "data:text/html,

The next image should not be loaded

" }); await Page.loadEventFired(); const { data } = await Page.captureScreenshot(); fs.writeFileSync((+new Date()) + '.png', Buffer.from(data, 'base64')); } catch (err) { console.error(err); } finally { await client.close(); } }).on('error', (err) => { console.error(err); });