How to capture full page screenshot in Selenium 4 using Bidi API's?

I want to capture a full page screenshot in selenium 4 using Bidi API's/Chrome developer tools.

A sample for generating console logs through Bidi apis. Want to capture the full page screenshot and store it in a local directory.

const { Builder } = require('selenium-webdriver');
(async () => {
  try {
    let driver = new Builder()

    const cdpConnection = await driver.createCDPConnection('page');
    await driver.onLogEvent(cdpConnection, function (event) {
    await driver.executeScript('console.log("CDP connection established")');
    await driver.quit();
  } catch (e) {
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum