Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How do I listen for onReportRendered when opening an embedded report with Puppeteer?

Hi.

 

I am trying to set up a way to get uniform, good-looking screenshots of our entire collection of reports using NodeJS. So far everything works perfectly, but at the moment the script just waits 16 seconds before taking the screenshots assuming the report has completed rendering. The problem is that some reports finish rendering in a couple seconds, whereas some of our heaviest reports take several minutes to render. The render times differ each time as well, since they depend on the current load on our backend. 

 

I noticed in DevTools that function onReportRendered is called when the report finishes rendering. Is there any way to tie into that function, so that my script will wait until either the report says it is rendered or a hardcoded timeout is reached before taking the screenshot?

 

onReportRendered in DevTools:

onReportRendered.png

onReportRendered2.png

 

Working script, but with hardcoded sleep():

 

 

 

const username = "user@company.org";
const password = "hardcoded";

const puppeteer = require('puppeteer');
const options = {headless: false};

const sleep = ms => new Promise((resolve) => { setTimeout(resolve, ms); });

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

  const screenshotFull = fileName => page.screenshot({
    path: `./images/${fileName}.png`,
  });

  await page.setViewport({ width: 1920, height: 1080 });
  await page.goto('https://app.powerbi.com/?noSignUpCheck=1', { waitUntil: 'networkidle0', timeout: 60000 });

  await page.waitForSelector('input[type="email"]');
  await page.type('input[type="email"]', username);
  await page.click('input[type="submit"]');

  await page.waitForSelector('#loginArea');
  await page.type('input[type="password"]', password);
  await page.click('#submitButton');
  await page.waitForSelector('#idSIButton9');
  await page.click('#idSIButton9');

  await sleep(15*1000);

  await page.goto('https://app.powerbi.com/reportEmbed?reportId={reportID}&groupId={workspaceID}&autoAuth=true&filterPaneEnabled=false&navContentPaneEnabled=false');
  await sleep(16*1000); // This is the line I want to replace by something smarter
  await screenshotFull('report-1'); 

  browser.close();
  process.exit(0); 
})();

 

 

 

 

0 REPLIES 0

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.