Hello World Master

Tutorials, articles and quizzes on Software Development

Code
Get a DOM element using Puppeteer > app > index.js
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');

  const getPtag = await page.$('p');
  const getInnerHTMLProperty = await getPtag.getProperty('innerText');
  const getPtagValues = await getInnerHTMLProperty.jsonValue();
  console.log(getPtagValues); 
  
  await browser.close();
})();