Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get element text puppeteer

 const puppeteer = require('puppeteer');

describe('My First Puppeteer Test', () => {
    it('should launch the browser', async function() {
        const browser = await puppeteer.launch({
             headless: false,
             slowMo: 50, 
             devtools: false,
        });
        const page = await browser.newPage();
        await page.goto('http://example.com/');
        const title = await page.title();
        const url = await page.url();
        const text = await page.$eval('h1', element => element.textContent)
        console.log('Text in the H1: ' + text);
        await browser.close();
    })
})
Comment

puppeteer inner text

await page.waitForSelector('your selector')
let element = await page.$('your selector')
let value = await page.evaluate(el => el.textContent, element)
Comment

PREVIOUS NEXT
Code Example
Javascript :: js canvas draw polygon 
Javascript :: expo build apk 
Javascript :: resolveJsonModule 
Javascript :: regex pattern for mobile number 
Javascript :: how to scroll down to the bottom of a div using javascript 
Javascript :: javascript get utc time 
Javascript :: nodejs sharp get image size 
Javascript :: string check javascript 
Javascript :: get url without query string 
Javascript :: onchange select dropdown jquery 
Javascript :: set onclick javascript 
Javascript :: discord javascript error cannot find module 
Javascript :: javascript sort array by Z-A in js 
Javascript :: how to let a function execute after 5 seconds javascript 
Javascript :: mongoose connection nodejs 
Javascript :: node print stdin 
Javascript :: mongodb add user 
Javascript :: javascript detect click outside element 
Javascript :: map over object javascript 
Javascript :: jquery scroll to id 
Javascript :: javascript clear text in textarea 
Javascript :: javascript check if undefined or null 
Javascript :: remove undefined values from object javascript 
Javascript :: delete empty values from object js 
Javascript :: jquery loop through json 
Javascript :: prime factorization javascript 
Javascript :: how to make a screen recording software with js 
Javascript :: como remover uma variável de um json 
Javascript :: fast xml parser nodejs 
Javascript :: background image url react 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =