get element text puppeteer

Solutions on MaxInterview for get element text puppeteer by the best coders in the world

showing results for - "get element text puppeteer"
Leuan
22 Nov 2019
1 const puppeteer = require('puppeteer');
2
3describe('My First Puppeteer Test', () => {
4    it('should launch the browser', async function() {
5        const browser = await puppeteer.launch({
6             headless: false,
7             slowMo: 50, 
8             devtools: false,
9        });
10        const page = await browser.newPage();
11        await page.goto('http://example.com/');
12        const title = await page.title();
13        const url = await page.url();
14        const text = await page.$eval('h1', element => element.textContent)
15        console.log('Text in the H1: ' + text);
16        await browser.close();
17    })
18})